Class ServiceQuery
java.lang.Object
com.complexible.stardog.plan.eval.service.ServiceQuery
- Direct Known Subclasses:
PlanNodeBodyServiceQuery
An immutable instance of a query on a given service. The query allows maintaining state about the
query as well as evaluating it.
Features of different types of ServiceQueries can be set using its options with
ServiceQueryOptions.
This is the preferred approach instead of extending the API with additional functions.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classBase service query builder class. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.complexible.stardog.index.statistics.Cardinalityprotected com.complexible.stardog.index.statistics.Cardinalityprotected final com.complexible.stardog.plan.eval.service.ServiceQueryOptions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.complexible.stardog.index.statistics.CardinalityalternativeDistinctValues(int theVar) If applicable, get an alternative estimate of the distinct values for the variable.booleancanServiceJoin(com.complexible.stardog.plan.PlanNode arg) com.complexible.stardog.index.statistics.CardinalitydistinctValues(int theVar) Get an estimate of the distinct values for the variableabstract booleancom.complexible.stardog.index.statistics.CardinalityestimateCardinality(com.complexible.stardog.db.ConnectableConnection theConn, Options theOption) Estimate cardinality of the service query.com.complexible.stardog.index.statistics.CardinalityestimateJoinCardinality(com.complexible.stardog.db.ConnectableConnection conn, Options options, com.complexible.stardog.plan.PlanNode joined) Estimate cardinality of the service query.abstract com.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluate(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo) Evaluate the querycom.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluate(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo, Set<Integer> theArgAssuredVars) Evaluate the query.com.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluateSilent(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo) Evaluate the query silently.com.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluateSilent(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo, Set<Integer> theArgAssuredVars) Evaluate the query silently.abstract Stringexplain(com.complexible.stardog.plan.PlanVarInfo theVarInfo, com.complexible.stardog.plan.util.QueryTermRenderer theRenderer) Returns an explain string for the service invocationabstract StringexplainVerbose(com.complexible.stardog.plan.PlanVarInfo theVarInfo, com.complexible.stardog.plan.util.QueryTermRenderer theRenderer) Returns an explain string for the service invocation in a parsable verbose formatcom.complexible.stardog.plan.eval.LazyValuesReturns Yes if the service may generate values which may not exist in the data (thus in the mapping dictionary)final <T> TGet a configuration option of the ServiceQueryabstract com.google.common.collect.ImmutableSet<Integer> abstract com.google.common.collect.ImmutableSet<Integer> What are the vars guaranteed to be bound by this query?com.complexible.stardog.index.statistics.Cardinalitycom.google.common.collect.ImmutableSet<Integer> com.google.common.collect.ImmutableSet<Integer> final OptionsReturn the options associated with this ServiceQuerycom.google.common.collect.ImmutableSet<Integer> The set of variables which should be bound by the argument of this query (if they are to be bound at all, membership in this set does not imply they are assured vars).The set of variables which cannot be bound by the argument of this query.com.google.common.collect.ImmutableSet<Integer> getUnsatisfiableConstraintsMessage(com.complexible.stardog.plan.PlanVarInfo varInfo) booleanReturns true if the node can return duplicate solutionsabstract inthashCode()final booleanIs the query body a SPARQL query? If so, we can apply some of our SPARQL transformations/optimizations.booleanisClosed()Is the service query "closed"? or can we still use it?final booleanIf the querysupportsJoinArgument(), are solutions returned in the same order as the join argument?com.complexible.stardog.plan.QueryTermService term (var or IRI) of this query.setCardinality(com.complexible.stardog.index.statistics.Cardinality theCardinality) voidsetNamespaces(Iterable<Namespace> theNamespaces) final booleanDoes the query support a join argument toevaluate(ExecutionContext, Operator, PlanVarInfo)?
-
Field Details
-
DEFAULT_CARDINALITY
public static final com.complexible.stardog.index.statistics.Cardinality DEFAULT_CARDINALITY -
mCardinality
protected com.complexible.stardog.index.statistics.Cardinality mCardinality -
mOptions
protected final com.complexible.stardog.plan.eval.service.ServiceQueryOptions mOptions
-
-
Constructor Details
-
ServiceQuery
-
-
Method Details
-
hasDuplicates
public boolean hasDuplicates()Returns true if the node can return duplicate solutions- Returns:
- true, if duplicates are possible
-
evaluate
public abstract com.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluate(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo) throws com.complexible.stardog.plan.eval.operator.OperatorException Evaluate the query- Parameters:
theArg- a SIP join argument, null if not present. Solutions from the argument which satisfy the join must retain all bindings, including those which are not used in the join. Note that variables in the argument may be unassured.- Throws:
com.complexible.stardog.plan.eval.operator.OperatorException
-
evaluate
public com.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluate(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo, Set<Integer> theArgAssuredVars) throws com.complexible.stardog.plan.eval.operator.OperatorException Evaluate the query. Allows for providing the assured variables of the argument. If not overwritten, defaults toevaluate(com.complexible.stardog.plan.eval.ExecutionContext, com.complexible.stardog.plan.eval.operator.Operator, com.complexible.stardog.plan.PlanVarInfo)- Parameters:
theArg- a SIP join argument, null if not present. Solutions from the argument which satisfy the join must retain all bindings, including * those which are not used in the join. Note that variables in the argument may be unassured.theArgAssuredVars- the set of assured variables in the argument- Throws:
com.complexible.stardog.plan.eval.operator.OperatorException
-
evaluateSilent
public com.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluateSilent(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo) throws com.complexible.stardog.plan.eval.operator.OperatorException Evaluate the query silently. We return a single empty solution if the service call fails- Throws:
com.complexible.stardog.plan.eval.operator.OperatorException
-
evaluateSilent
public com.complexible.stardog.plan.eval.operator.SolutionIterator<?> evaluateSilent(com.complexible.stardog.plan.eval.ExecutionContext theContext, com.complexible.stardog.plan.eval.operator.Operator theArg, com.complexible.stardog.plan.PlanVarInfo theVarInfo, Set<Integer> theArgAssuredVars) throws com.complexible.stardog.plan.eval.operator.OperatorException Evaluate the query silently. We return a single empty solution if the service call fails. Allows for providing the assured variables of the argument. If not overwritten, defaults toevaluateSilent(com.complexible.stardog.plan.eval.ExecutionContext, com.complexible.stardog.plan.eval.operator.Operator, com.complexible.stardog.plan.PlanVarInfo)- Throws:
com.complexible.stardog.plan.eval.operator.OperatorException
-
generatesValues
public com.complexible.stardog.plan.eval.LazyValues generatesValues()Returns Yes if the service may generate values which may not exist in the data (thus in the mapping dictionary) -
getAssuredVars
What are the vars guaranteed to be bound by this query? -
getSubjectVars
-
getPredicateVars
-
getObjectVars
-
getContextVars
-
getAllVars
-
explain
public abstract String explain(com.complexible.stardog.plan.PlanVarInfo theVarInfo, com.complexible.stardog.plan.util.QueryTermRenderer theRenderer) Returns an explain string for the service invocation- Returns:
- an explain string for the service invocation or
nullif there is no custom explanation
-
explainVerbose
public abstract String explainVerbose(com.complexible.stardog.plan.PlanVarInfo theVarInfo, com.complexible.stardog.plan.util.QueryTermRenderer theRenderer) Returns an explain string for the service invocation in a parsable verbose format- Returns:
- an explain string in verbose format
-
serviceTerm
public com.complexible.stardog.plan.QueryTerm serviceTerm()Service term (var or IRI) of this query. -
getRequiredInputBindings
The set of variables which should be bound by the argument of this query (if they are to be bound at all, membership in this set does not imply they are assured vars). A service may compute some binding based on "input" data. If this data is not available, the service will not create bindings for it and the result will be incorrect. A non-empty set returned here implies the querysupports a join arg. -
getRequiredUnboundOutputs
The set of variables which cannot be bound by the argument of this query. A service may bind "output" of a computation to this set of vars. Bindings cannot exist as they would be overwritten. Join must be done externally. -
estimateCardinality
public com.complexible.stardog.index.statistics.Cardinality estimateCardinality(com.complexible.stardog.db.ConnectableConnection theConn, Options theOption) Estimate cardinality of the service query. -
getCardinality
public com.complexible.stardog.index.statistics.Cardinality getCardinality() -
setCardinality
public ServiceQuery setCardinality(com.complexible.stardog.index.statistics.Cardinality theCardinality) -
distinctValues
public com.complexible.stardog.index.statistics.Cardinality distinctValues(int theVar) Get an estimate of the distinct values for the variable- Parameters:
theVar- the variable- Returns:
- an estimation of the number of distinct values for the variable in the ServiceQuery
-
alternativeDistinctValues
public com.complexible.stardog.index.statistics.Cardinality alternativeDistinctValues(int theVar) If applicable, get an alternative estimate of the distinct values for the variable. The alternative estimation function is used for theimpact analysis. Changing the distinct values estimations can impact the join cardinality with the service query. For example, an alternative distinct values estimations could take the position of the variable in the service query pattern into account.- Parameters:
theVar- the variable- Returns:
- the estimate
-
estimateJoinCardinality
public com.complexible.stardog.index.statistics.Cardinality estimateJoinCardinality(com.complexible.stardog.db.ConnectableConnection conn, Options options, com.complexible.stardog.plan.PlanNode joined) Estimate cardinality of the service query. todo: this method should return Selectivity instead of Cardinality, change this in Stardog 9 -
isClosed
public boolean isClosed()Is the service query "closed"? or can we still use it? -
isBodySparqlQuery
public final boolean isBodySparqlQuery()Is the query body a SPARQL query? If so, we can apply some of our SPARQL transformations/optimizations. -
supportsJoinArgument
public final boolean supportsJoinArgument()Does the query support a join argument toevaluate(ExecutionContext, Operator, PlanVarInfo)? -
canServiceJoin
public boolean canServiceJoin(com.complexible.stardog.plan.PlanNode arg) -
preservesJoinArgumentOrdering
public final boolean preservesJoinArgumentOrdering()If the querysupportsJoinArgument(), are solutions returned in the same order as the join argument? -
setNamespaces
-
getNamespaces
-
getOptions
Return the options associated with this ServiceQuery- Returns:
- the options
-
get
Get a configuration option of the ServiceQuery- Type Parameters:
T- the type of the value of the option- Parameters:
theOption- the option- Returns:
- the value of the option, or null if it's not set and there is no default
-
hashCode
public abstract int hashCode() -
equals
-
toBuilder
-
getUnsatisfiableConstraintsMessage
-