net.sf.sparql.benchmarking.operations.query.callables
Class WrapperQueryCallable<T extends Options,TCallable extends AbstractQueryCallable<T>>

java.lang.Object
  extended by net.sf.sparql.benchmarking.operations.AbstractOperationCallable<T>
      extended by net.sf.sparql.benchmarking.operations.query.callables.AbstractQueryCallable<T>
          extended by net.sf.sparql.benchmarking.operations.query.callables.WrapperQueryCallable<T,TCallable>
Type Parameters:
T - Options type
TCallable - Callable type
All Implemented Interfaces:
Callable<OperationRun>, OperationCallable<T>
Direct Known Subclasses:
AbstractScalarValueCallable

public abstract class WrapperQueryCallable<T extends Options,TCallable extends AbstractQueryCallable<T>>
extends AbstractQueryCallable<T>

A decorator to allow query callables to have parts of their behaviour modified without extending them directly. This is useful for making decorators that change behaviour for both local and remote queries.

Note that we specifically prevent decoration of the call() method because we want it to call our versions of the relevant protected methods. If we simply decorated this method and called call() on the underlying callable then its versions of those methods would be called rather than our decorated versions and the decorator would have no effect.

Author:
rvesse

Constructor Summary
WrapperQueryCallable(Runner<T> runner, T options, TCallable callable)
          Creates a new decorator
 
Method Summary
 QueryRun call()
          Runs the Query counting the number of Results
protected  long countResults(T options, boolean result)
          Counts the results for queries that return a boolean
protected  long countResults(T options, Model m)
          Counts results for queries that return a model.
protected  long countResults(T options, ResultSet rset)
          Counts results for queries that return a result set
protected  QueryExecution createQueryExecution(Query query)
          Creates the query execution to use for the query
protected  void customizeRequest(QueryExecution qe)
          Provides derived implementations the option to customize the query execution before actually executing the query e.g.
protected  Query getQuery()
          Gets the query to be run
 
Methods inherited from class net.sf.sparql.benchmarking.operations.AbstractOperationCallable
cancel, getOptions, getRunner, isCancelled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrapperQueryCallable

public WrapperQueryCallable(Runner<T> runner,
                            T options,
                            TCallable callable)
Creates a new decorator

Parameters:
runner - Runner
options - Options
callable - Callable to decorate
Method Detail

call

public final QueryRun call()
Description copied from class: AbstractQueryCallable
Runs the Query counting the number of Results

Specified by:
call in interface Callable<OperationRun>
Overrides:
call in class AbstractQueryCallable<T extends Options>

getQuery

protected Query getQuery()
Description copied from class: AbstractQueryCallable
Gets the query to be run

Specified by:
getQuery in class AbstractQueryCallable<T extends Options>
Returns:
Query

countResults

protected long countResults(T options,
                            boolean result)
Description copied from class: AbstractQueryCallable
Counts the results for queries that return a boolean

The default implementation always returns 1

Overrides:
countResults in class AbstractQueryCallable<T extends Options>
Parameters:
options - Options
result - Result
Returns:
Number of results

countResults

protected long countResults(T options,
                            Model m)
Description copied from class: AbstractQueryCallable
Counts results for queries that return a model.

The default implementation returns the size of the model

Overrides:
countResults in class AbstractQueryCallable<T extends Options>
Parameters:
options - Options
m - Model
Returns:
Number of results

countResults

protected long countResults(T options,
                            ResultSet rset)
Description copied from class: AbstractQueryCallable
Counts results for queries that return a result set

The default implementation either returns OperationRun.UNKNOWN if the options indicate that counting is disabled or iterates over the results to count them.

Overrides:
countResults in class AbstractQueryCallable<T extends Options>
Parameters:
options - Options
rset - Result Set
Returns:
Number of results

customizeRequest

protected void customizeRequest(QueryExecution qe)
Description copied from class: AbstractQueryCallable
Provides derived implementations the option to customize the query execution before actually executing the query e.g. to add custom parameters

The default implementation does nothing.

Overrides:
customizeRequest in class AbstractQueryCallable<T extends Options>
Parameters:
qe - Query Execution

createQueryExecution

protected QueryExecution createQueryExecution(Query query)
Description copied from class: AbstractQueryCallable
Creates the query execution to use for the query

Specified by:
createQueryExecution in class AbstractQueryCallable<T extends Options>
Parameters:
query - Query
Returns:
Query execution


Copyright © 2014. All Rights Reserved.