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

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

public abstract class AbstractQueryCallable<T extends Options>
extends AbstractOperationCallable<T>

Abstract callable for queries

Author:
rvesse

Constructor Summary
AbstractQueryCallable(Runner<T> runner, T options)
          Creates a new callable
 
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 abstract  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 abstract  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

AbstractQueryCallable

public AbstractQueryCallable(Runner<T> runner,
                             T options)
Creates a new callable

Parameters:
runner - Runner
options - Options
Method Detail

getQuery

protected abstract Query getQuery()
Gets the query to be run

Returns:
Query

countResults

protected long countResults(T options,
                            boolean result)
Counts the results for queries that return a boolean

The default implementation always returns 1

Parameters:
options - Options
result - Result
Returns:
Number of results

countResults

protected long countResults(T options,
                            Model m)
Counts results for queries that return a model.

The default implementation returns the size of the model

Parameters:
options - Options
m - Model
Returns:
Number of results

countResults

protected long countResults(T options,
                            ResultSet rset)
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.

Parameters:
options - Options
rset - Result Set
Returns:
Number of results

customizeRequest

protected void customizeRequest(QueryExecution qe)
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.

Parameters:
qe - Query Execution

call

public QueryRun call()
Runs the Query counting the number of Results


createQueryExecution

protected abstract QueryExecution createQueryExecution(Query query)
Creates the query execution to use for the query

Parameters:
query - Query
Returns:
Query execution


Copyright © 2014. All Rights Reserved.