Class FederationEvalStrategy
java.lang.Object
org.eclipse.rdf4j.query.algebra.evaluation.impl.DefaultEvaluationStrategy
org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategy
org.eclipse.rdf4j.federated.evaluation.FederationEvalStrategy
- All Implemented Interfaces:
EvaluationStrategy
,FederatedServiceResolver
,FederatedServiceResolverClient
,UUIDable
- Direct Known Subclasses:
SailFederationEvalStrategy
,SparqlFederationEvalStrategy
Base class for the Evaluation strategies.
- Author:
- Andreas Schwarte
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected SourceSelectionCache
protected Executor
protected FederationContext
Fields inherited from class org.eclipse.rdf4j.query.algebra.evaluation.impl.DefaultEvaluationStrategy
dataset, serviceResolver, tripleSource
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionevaluate
(ConjunctiveFilterExpr node, BindingSet bindings) evaluate
(FilterExpr node, BindingSet bindings) evaluate
(DescribeOperator operator, BindingSet bindings) evaluate
(TupleExpr expr, BindingSet bindings) Evaluates the tuple expression against the supplied triple source with the specified set of variable bindings as input.evaluate
(ValueExpr expr, BindingSet bindings) Gets the value of this expression.protected CloseableIteration
<BindingSet, QueryEvaluationException> evaluateAtStatementSources
(Object preparedQuery, List<StatementSource> statementSources, QueryInfo queryInfo) protected CloseableIteration
<BindingSet, QueryEvaluationException> evaluateAtStatementSources
(String preparedQuery, List<StatementSource> statementSources, QueryInfo queryInfo) protected CloseableIteration
<BindingSet, QueryEvaluationException> evaluateAtStatementSources
(TupleExpr preparedQuery, List<StatementSource> statementSources, QueryInfo queryInfo) evaluateBoundJoinStatementPattern
(StatementTupleExpr stmt, List<BindingSet> bindings) Evaluate a bound join at the relevant endpoint, i.e.evaluateExclusiveGroup
(ExclusiveGroup group, BindingSet bindings) protected CloseableIteration
<BindingSet, QueryEvaluationException> evaluateExclusiveTupleExpr
(ExclusiveTupleExpr expr, BindingSet bindings) Evaluate anExclusiveTupleExpr
.evaluateGroupedCheck
(CheckStatementPattern stmt, List<BindingSet> bindings) Perform a grouped check at the relevant endpoints, i.e.protected CloseableIteration
<BindingSet, QueryEvaluationException> evaluateLeftJoin
(FedXLeftJoin leftJoin, BindingSet bindings) Evaluate aFedXLeftJoin
(i.e.evaluateNaryUnion
(NUnion union, BindingSet bindings) evaluateNJoin
(NJoin join, BindingSet bindings) evaluateService
(FedXService service, List<BindingSet> bindings) Evaluate a SERVICE using vectored evaluation, taking the provided bindings as input.evaluateService
(FedXService service, BindingSet bindings) evaluateSingleSourceQuery
(SingleSourceQuery query, BindingSet bindings) protected abstract CloseableIteration
<BindingSet, QueryEvaluationException> executeJoin
(ControlledWorkerScheduler<BindingSet> joinScheduler, CloseableIteration<BindingSet, QueryEvaluationException> leftIter, TupleExpr rightArg, Set<String> joinVariables, BindingSet bindings, QueryInfo queryInfo) Execute the join in a separate thread using some join executor.Retrieve the statements matching the provided subject, predicate and object value from the federation members.optimize
(TupleExpr expr, EvaluationStatistics evaluationStatistics, BindingSet bindings) Execute theQueryOptimizerPipeline
on the givenTupleExpr
to optimize its execution plan.protected void
optimizeExclusiveExpressions
(TupleExpr query, QueryInfo queryInfo, GenericInfoOptimizer info) OptimizeExclusiveTupleExpr
, e.g.protected void
optimizeJoinOrder
(TupleExpr query, QueryInfo queryInfo, GenericInfoOptimizer info) performSourceSelection
(List<Endpoint> members, SourceSelectionCache cache, QueryInfo queryInfo, GenericInfoOptimizer info) Perform source selection for all statements of the query.precompile
(TupleExpr expr, QueryEvaluationContext context) precompile
(ValueExpr expr, QueryEvaluationContext context) protected QueryValueEvaluationStep
prepare
(ConjunctiveFilterExpr node, QueryEvaluationContext context) protected QueryValueEvaluationStep
prepare
(FilterExpr node, QueryEvaluationContext context) protected QueryEvaluationStep
prepareExclusiveTupleExpr
(ExclusiveTupleExpr expr, QueryEvaluationContext context) protected QueryEvaluationStep
prepareLeftJoin
(FedXLeftJoin leftJoin, QueryEvaluationContext context) prepareNaryUnion
(NUnion union, QueryEvaluationContext context) protected QueryEvaluationStep
prepareNJoin
(NJoin join, QueryEvaluationContext context) protected boolean
propagateServices
(List<Service> serviceNodes) Whether to propagate aSingleSourceQuery
containing SERVICE clauses.Methods inherited from class org.eclipse.rdf4j.query.algebra.evaluation.impl.DefaultEvaluationStrategy
evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, evaluate, getCollectionFactory, getFederatedServiceResolver, getLimit, getQueryEvaluationMode, getService, getUUID, getVarValue, isReducedOrDistinct, isTrue, isTrue, precompile, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, prepare, setCollectionFactory, setFederatedServiceResolver, setOptimizerPipeline, setQueryEvaluationMode, setTrackResultSize, setTrackTime, supplyBinaryValueEvaluation, supplyUnaryValueEvaluation
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy
isTrackResultSize, makeQueue, makeSet
-
Field Details
-
executor
-
cache
-
federationContext
-
-
Constructor Details
-
FederationEvalStrategy
-
-
Method Details
-
optimize
public TupleExpr optimize(TupleExpr expr, EvaluationStatistics evaluationStatistics, BindingSet bindings) Description copied from class:DefaultEvaluationStrategy
Execute theQueryOptimizerPipeline
on the givenTupleExpr
to optimize its execution plan.- Specified by:
optimize
in interfaceEvaluationStrategy
- Overrides:
optimize
in classDefaultEvaluationStrategy
- Parameters:
expr
- theTupleExpr
to optimize.evaluationStatistics
- this param is ignored!bindings
- a-priori bindings supplied for the query, which can potentially be inlined.- Returns:
- the optimized
TupleExpr
. - See Also:
-
performSourceSelection
protected Set<Endpoint> performSourceSelection(List<Endpoint> members, SourceSelectionCache cache, QueryInfo queryInfo, GenericInfoOptimizer info) Perform source selection for all statements of the query. As a result of this method all statement nodes are annotated with their relevant sources.- Parameters:
members
-cache
-queryInfo
-info
-- Returns:
- the set of relevant endpoints for the entire query
-
optimizeJoinOrder
-
propagateServices
Whether to propagate aSingleSourceQuery
containing SERVICE clauses. By default, the query is always evaluated within the FedX engine if it contains a SERVICE clause.Customized implementation may propagate a
SingleSourceQuery
including the SERVICE clause (e.g. for Wikidata the Label service can only be accessed in the wikidata endpoint.- Parameters:
serviceNodes
-- Returns:
- if
true
, aSingleSourceQuery
containing SERVICE clauses is propagated as-is
-
optimizeExclusiveExpressions
protected void optimizeExclusiveExpressions(TupleExpr query, QueryInfo queryInfo, GenericInfoOptimizer info) OptimizeExclusiveTupleExpr
, e.g. restructure the exclusive parts of the query AST.- Parameters:
query
-queryInfo
-info
-
-
evaluate
public CloseableIteration<BindingSet,QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException Description copied from interface:EvaluationStrategy
Evaluates the tuple expression against the supplied triple source with the specified set of variable bindings as input.- Specified by:
evaluate
in interfaceEvaluationStrategy
- Overrides:
evaluate
in classDefaultEvaluationStrategy
- Parameters:
expr
- The Tuple Expression to evaluatebindings
- The variables bindings to use for evaluating the expression, if applicable.- Returns:
- A closeable iterator over the variable binding sets that match the tuple expression.
- Throws:
QueryEvaluationException
-
precompile
public QueryEvaluationStep precompile(TupleExpr expr, QueryEvaluationContext context) throws QueryEvaluationException - Specified by:
precompile
in interfaceEvaluationStrategy
- Overrides:
precompile
in classDefaultEvaluationStrategy
- Throws:
QueryEvaluationException
-
getStatements
public CloseableIteration<Statement,QueryEvaluationException> getStatements(QueryInfo queryInfo, Resource subj, IRI pred, Value obj, Resource... contexts) throws RepositoryException, MalformedQueryException, QueryEvaluationException Retrieve the statements matching the provided subject, predicate and object value from the federation members.For a bound statement, i.e. a statement with no free variables, the statement itself is returned if some member has this statement, an empty iteration otherwise.
If the statement has free variables, i.e. one of the provided arguments in
null
, the union of results from relevant statement sources is constructed.- Parameters:
subj
-pred
-obj
-contexts
-- Returns:
- the statement iteration
- Throws:
RepositoryException
MalformedQueryException
QueryEvaluationException
-
evaluateService
public CloseableIteration<BindingSet,QueryEvaluationException> evaluateService(FedXService service, BindingSet bindings) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
evaluateSingleSourceQuery
public CloseableIteration<BindingSet,QueryEvaluationException> evaluateSingleSourceQuery(SingleSourceQuery query, BindingSet bindings) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
evaluateNJoin
public CloseableIteration<BindingSet,QueryEvaluationException> evaluateNJoin(NJoin join, BindingSet bindings) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
prepareNJoin
protected QueryEvaluationStep prepareNJoin(NJoin join, QueryEvaluationContext context) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
evaluateLeftJoin
protected CloseableIteration<BindingSet,QueryEvaluationException> evaluateLeftJoin(FedXLeftJoin leftJoin, BindingSet bindings) throws QueryEvaluationException Evaluate aFedXLeftJoin
(i.e. an OPTIONAL clause)- Parameters:
leftJoin
-bindings
-- Returns:
- the resulting iteration
- Throws:
QueryEvaluationException
- See Also:
-
prepareLeftJoin
protected QueryEvaluationStep prepareLeftJoin(FedXLeftJoin leftJoin, QueryEvaluationContext context) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
evaluateNaryUnion
public CloseableIteration<BindingSet,QueryEvaluationException> evaluateNaryUnion(NUnion union, BindingSet bindings) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
prepareNaryUnion
public QueryEvaluationStep prepareNaryUnion(NUnion union, QueryEvaluationContext context) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
executeJoin
protected abstract CloseableIteration<BindingSet,QueryEvaluationException> executeJoin(ControlledWorkerScheduler<BindingSet> joinScheduler, CloseableIteration<BindingSet, QueryEvaluationException> leftIter, TupleExpr rightArg, Set<String> joinVariables, BindingSet bindings, QueryInfo queryInfo) throws QueryEvaluationExceptionExecute the join in a separate thread using some join executor. Join executors are for instance: -SynchronousJoin
-SynchronousBoundJoin
-ControlledWorkerJoin
-ControlledWorkerBoundJoin
For endpoint federation use controlled worker bound join, for local federation use controlled worker join. The other operators are there for completeness. Useexecutor
to execute the join (it is a runnable).- Parameters:
joinScheduler
-leftIter
-rightArg
-joinVariables
-bindings
-- Returns:
- the result
- Throws:
QueryEvaluationException
-
evaluateExclusiveGroup
public abstract CloseableIteration<BindingSet,QueryEvaluationException> evaluateExclusiveGroup(ExclusiveGroup group, BindingSet bindings) throws RepositoryException, MalformedQueryException, QueryEvaluationException -
evaluateExclusiveTupleExpr
protected CloseableIteration<BindingSet,QueryEvaluationException> evaluateExclusiveTupleExpr(ExclusiveTupleExpr expr, BindingSet bindings) throws RepositoryException, MalformedQueryException, QueryEvaluationException Evaluate anExclusiveTupleExpr
. The default implementation converts the given expression to a SELECT query string and evaluates it at the source.- Parameters:
expr
-bindings
-- Returns:
- the result
- Throws:
RepositoryException
MalformedQueryException
QueryEvaluationException
-
prepareExclusiveTupleExpr
protected QueryEvaluationStep prepareExclusiveTupleExpr(ExclusiveTupleExpr expr, QueryEvaluationContext context) throws RepositoryException, MalformedQueryException, QueryEvaluationException -
evaluateBoundJoinStatementPattern
public abstract CloseableIteration<BindingSet,QueryEvaluationException> evaluateBoundJoinStatementPattern(StatementTupleExpr stmt, List<BindingSet> bindings) throws QueryEvaluationException Evaluate a bound join at the relevant endpoint, i.e. i.e. for a group of bindings retrieve results for the bound statement from the relevant endpoints- Parameters:
stmt
-bindings
-- Returns:
- the result iteration
- Throws:
QueryEvaluationException
-
evaluateGroupedCheck
public abstract CloseableIteration<BindingSet,QueryEvaluationException> evaluateGroupedCheck(CheckStatementPattern stmt, List<BindingSet> bindings) throws QueryEvaluationException Perform a grouped check at the relevant endpoints, i.e. for a group of bindings keep only those for which at least one endpoint provides a result to the bound statement.- Parameters:
stmt
-bindings
-- Returns:
- the result iteration
- Throws:
QueryEvaluationException
-
evaluateService
public CloseableIteration<BindingSet,QueryEvaluationException> evaluateService(FedXService service, List<BindingSet> bindings) throws QueryEvaluationException Evaluate a SERVICE using vectored evaluation, taking the provided bindings as input. SeeControlledWorkerBoundJoin
andFedXConfig.getEnableServiceAsBoundJoin()
- Parameters:
service
-bindings
-- Returns:
- the result iteration
- Throws:
QueryEvaluationException
-
evaluate
public Value evaluate(ValueExpr expr, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException Description copied from interface:EvaluationStrategy
Gets the value of this expression.- Specified by:
evaluate
in interfaceEvaluationStrategy
- Overrides:
evaluate
in classDefaultEvaluationStrategy
- Parameters:
expr
-bindings
- The variables bindings to use for evaluating the expression, if applicable.- Returns:
- The Value that this expression evaluates to, or null if the expression could not be evaluated.
- Throws:
ValueExprEvaluationException
QueryEvaluationException
-
precompile
public QueryValueEvaluationStep precompile(ValueExpr expr, QueryEvaluationContext context) throws ValueExprEvaluationException, QueryEvaluationException - Specified by:
precompile
in interfaceEvaluationStrategy
- Overrides:
precompile
in classDefaultEvaluationStrategy
- Throws:
ValueExprEvaluationException
QueryEvaluationException
-
evaluate
public Value evaluate(FilterExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException -
prepare
protected QueryValueEvaluationStep prepare(FilterExpr node, QueryEvaluationContext context) throws ValueExprEvaluationException, QueryEvaluationException -
evaluate
public Value evaluate(ConjunctiveFilterExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException -
prepare
protected QueryValueEvaluationStep prepare(ConjunctiveFilterExpr node, QueryEvaluationContext context) throws ValueExprEvaluationException, QueryEvaluationException -
evaluate
public CloseableIteration<BindingSet,QueryEvaluationException> evaluate(DescribeOperator operator, BindingSet bindings) throws QueryEvaluationException - Overrides:
evaluate
in classDefaultEvaluationStrategy
- Throws:
QueryEvaluationException
-
evaluateAtStatementSources
protected CloseableIteration<BindingSet,QueryEvaluationException> evaluateAtStatementSources(Object preparedQuery, List<StatementSource> statementSources, QueryInfo queryInfo) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
evaluateAtStatementSources
protected CloseableIteration<BindingSet,QueryEvaluationException> evaluateAtStatementSources(String preparedQuery, List<StatementSource> statementSources, QueryInfo queryInfo) throws QueryEvaluationException - Throws:
QueryEvaluationException
-
evaluateAtStatementSources
protected CloseableIteration<BindingSet,QueryEvaluationException> evaluateAtStatementSources(TupleExpr preparedQuery, List<StatementSource> statementSources, QueryInfo queryInfo) throws QueryEvaluationException - Throws:
QueryEvaluationException
-