Class BaseForExecOpSequentialBindJoin<QueryType extends Query,MemberType extends FederationMember>
java.lang.Object
se.liu.ida.hefquin.engine.queryplan.executable.impl.ops.BaseForExecOps
se.liu.ida.hefquin.engine.queryplan.executable.impl.ops.UnaryExecutableOpBase
se.liu.ida.hefquin.engine.queryplan.executable.impl.ops.BaseForExecOpSequentialBindJoin<QueryType,MemberType>
- All Implemented Interfaces:
StatsProvider,ExecutableOperator,UnaryExecutableOp
- Direct Known Subclasses:
BaseForExecOpSequentialBindJoinSPARQL,ExecOpSequentialBindJoinBRTPF
public abstract class BaseForExecOpSequentialBindJoin<QueryType extends Query,MemberType extends FederationMember>
extends UnaryExecutableOpBase
A generic implementation of batch-based bind-join algorithm that performs
the bind-join requests sequentially, one after another, for which it uses
executable request operators.
The implementation is generic in the sense that it works with any type of
request operator. Each concrete implementation that extends this base class
needs to implement the
createExecutableReqOp(Set) method to create
the request operators with the types of requests that are specific to that
concrete implementation.
The algorithm collects solution mappings from the input. Once enough
solution mappings have arrived, the algorithm creates the corresponding
request (see above) and sends this request to the federation member (the
algorithm may even decide to split the input batch into smaller batches
for multiple requests; see below). The response to such a request is the
subset of the solutions for the query/pattern of this operator that are
join partners for at least one of the solutions that were used for creating
the request. After receiving such a response, the algorithm locally joins
the solutions from the response with the solutions in the batch used for
creating the request, and outputs the resulting joined solutions (if any).
Thereafter, the algorithm moves on to collect the next solution mappings
from the input, until it can do the next request, etc.
This implementation is capable of separating out each input solution mapping
that assigns a blank node to any of the join variables. Then, such solution
mappings are not even considered when creating the requests because they
cannot have any join partners in the results obtained from the federation
member. Of course, in case the algorithm is used with outer-join semantics,
these solution mappings are still returned to the output (without joining
them with anything).
A feature of this implementation is that, in case a request operator fails,
this implementation automatically reduces the batch size for requests and,
then, tries to re-process (with the reduced request batch size) the input
solution mappings for which the request operator failed.
Another feature of this implementation is that it can switch into a
full-retrieval mode as soon as there is an input solution mapping that
does not have a binding for any of the join variables (which may happen
only in cases in which at least one of the join variables is a certain
variable). Such an input solution mapping is compatible with (and, thus,
can be joined with) every solution mapping that the federation member has
for the query/pattern of this bind-join operator. Therefore, when switching
into full-retrieval mode, this implementation performs a request to retrieve
the complete set of all these solution mappings and, then, uses this set to
find join partners for the current and the future batches of input solution
mappings (because, with the complete set available locally, there is no need
anymore to issue further bind-join requests). This capability relies on the
createExecutableReqOpForAll() method that needs to be provided by
each concrete implementation that extends this base class.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanprotected final List<SolutionMapping> This set is used to collect up the input solution mappings (obtained from the child operator in the execution plan) for which the next bind-join request will ask for possible join partners.protected final Set<org.apache.jena.sparql.engine.binding.Binding> This set is used to collect up solution mappings that will be used to form the next bind-join request.static final intprotected final MemberTypeprotected Iterable<SolutionMapping> In case that this operator had to switch to full-retrieval mode, this one contains all solution mappings retrieved for the query of this operator.protected static final intThe minimum value to whichrequestBlockSizecan be reduced.protected intprotected final QueryTypeprotected intThe number of solution mappings that this operator uses for each of the bind join requests.protected booleanprotected ExecutableOperatorStatsprotected ExecutableOperatorStatsprotected final booleanprotected final Set<org.apache.jena.sparql.core.Var> Fields inherited from class se.liu.ida.hefquin.engine.queryplan.executable.impl.ops.BaseForExecOps
collectExceptions, qpInfo -
Constructor Summary
ConstructorsConstructorDescriptionBaseForExecOpSequentialBindJoin(QueryType query, Set<org.apache.jena.sparql.core.Var> varsInQuery, MemberType fm, ExpectedVariables inputVars, boolean useOuterJoinSemantics, int batchSize, boolean collectExceptions, QueryPlanningInfo qpInfo) -
Method Summary
Modifier and TypeMethodDescriptionprotected void_concludeExecution(IntermediateResultElementSink sink, ExecutionContext execCxt) Implementations of this function need to conclude the execution of this operator and send the remaining result elements (if any) to the given sink.protected void_process(SolutionMapping inputSolMap, IntermediateResultElementSink sink, ExecutionContext execCxt) Implementations of this function need to process the given solution mapping as input and send the produced result elements (if any) to the given sink.protected void_processJoinableInput(SolutionMapping inputSolMap, org.apache.jena.sparql.engine.binding.Binding inputSolMapRestricted, IntermediateResultElementSink sink, ExecutionContext execCxt) Makes sure that the given solution mapping will be considered for the next bind-join request, and performs that request if enough solution mappings have been accumulated.protected booleanalreadyCovered(org.apache.jena.sparql.engine.binding.Binding inputSolMapRestricted) static booleanareAllJoinVarsAreCertain(Set<org.apache.jena.sparql.core.Var> varsInQuery, ExpectedVariables inputVars) Returnstrueif the given set of variables does not overlap with the possible-variables set of the givenExpectedVariables.protected voidconsumeMySink(BaseForExecOpSequentialBindJoin<QueryType, MemberType>.MyIntermediateResultElementSink mySink, IntermediateResultElementSink outputSink) protected abstract NullaryExecutableOpcreateExecutableReqOp(Set<org.apache.jena.sparql.engine.binding.Binding> solMaps) Implementations of this function should create an executable operator that can perform a bind join request in which the query of this bind join operator is combined with the given solution mappings.protected abstract NullaryExecutableOpImplementations of this function should create an executable operator that can perform a request to retrieve all solution mappings for the query of this operator (i.e., not a bind-join request).protected ExecutableOperatorStatsImplprotected voidjoinInFullRetrievalMode(Iterable<SolutionMapping> batchOfSolMaps, IntermediateResultElementSink sink) protected voidjoinInFullRetrievalMode(SolutionMapping inputSolMap, IntermediateResultElementSink sink) protected voidprotected booleanReducesrequestBlockSizeto its current value divided by 2 if the resulting value would still be greater or equal tominimumRequestBlockSize.voidprotected voidPerforms a request to retrieve all solution mappings for the query of this operator (seecreateExecutableReqOpForAll()) and puts the retrieved solution mappings intofullResult.Methods inherited from class se.liu.ida.hefquin.engine.queryplan.executable.impl.ops.UnaryExecutableOpBase
_process, concludeExecution, getStats, process, processMethods inherited from class se.liu.ida.hefquin.engine.queryplan.executable.impl.ops.BaseForExecOps
getExceptionsCaughtDuringExecution, getQueryPlanningInfo, recordExceptionCaughtDuringExecutionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface se.liu.ida.hefquin.engine.queryplan.executable.ExecutableOperator
getExceptionsCaughtDuringExecution, getQueryPlanningInfo
-
Field Details
-
DEFAULT_BATCH_SIZE
public static final int DEFAULT_BATCH_SIZE- See Also:
-
query
-
fm
-
varsInQuery
-
useOuterJoinSemantics
protected final boolean useOuterJoinSemantics -
allJoinVarsAreCertain
protected final boolean allJoinVarsAreCertain -
requestBlockSize
protected int requestBlockSizeThe number of solution mappings that this operator uses for each of the bind join requests. This number may be adapted at runtime. -
minimumRequestBlockSize
protected static final int minimumRequestBlockSizeThe minimum value to whichrequestBlockSizecan be reduced.- See Also:
-
currentBatch
This set is used to collect up the input solution mappings (obtained from the child operator in the execution plan) for which the next bind-join request will ask for possible join partners. Note that these are not necessarily the solution mappings to be used for forming the next bind-join request; those are collected in parallel incurrentSolMapsForRequest. Once the response received for the next bind-join request has been handled, this set will be cleared (and then populated again, by using the next input solution mappings that will arrive afterwards). -
currentSolMapsForRequest
This set is used to collect up solution mappings that will be used to form the next bind-join request. These solution mappings will be created by restricting relevant input solution mappings (obtained from the child operator in the execution plan) to the join variables; i.e., projecting away the non-join variables, as the bindings for these do not need to be shipped in the bind-join requests. The corresponding input solution mappings from which the solution mappings in this set have been created are collected in parallel incurrentBatch. It is possible that multiple input solution mappings may result in the same restricted solution mapping. Once the response received for the next bind-join request has been handled, this set will be cleared (and then populated again, by using the next input solution mappings that will arrive afterwards). -
fullResult
In case that this operator had to switch to full-retrieval mode, this one contains all solution mappings retrieved for the query of this operator. -
requestBlockSizeWasReduced
protected boolean requestBlockSizeWasReduced -
numberOfRequestOpsUsed
protected int numberOfRequestOpsUsed -
numOfSolMapsRetrievedPerReqOp
-
statsOfFirstReqOp
-
statsOfLastReqOp
-
-
Constructor Details
-
BaseForExecOpSequentialBindJoin
public BaseForExecOpSequentialBindJoin(QueryType query, Set<org.apache.jena.sparql.core.Var> varsInQuery, MemberType fm, ExpectedVariables inputVars, boolean useOuterJoinSemantics, int batchSize, boolean collectExceptions, QueryPlanningInfo qpInfo) - Parameters:
query- - the graph pattern (or other kind of query) to be evaluated (in a bind-join manner) at the federation member given as 'fm'varsInQuery- - the variables that occur in the 'query'fm- - the federation member targeted by this operatorinputVars- - the variables to be expected in the solution mappings that will be pushed as input to this operatoruseOuterJoinSemantics- -trueif the 'query' is to be evaluated under outer-join semantics;falsefor inner-join semanticsbatchSize- - the number of solution mappings to be included in each bind-join request; this value must not be smaller thanminimumRequestBlockSizecollectExceptions- -trueif this operator has to collect exceptions (which is handled entirely by one of the super classes);falseif the operator should immediately throw everyExecOpExecutionException
-
-
Method Details
-
areAllJoinVarsAreCertain
public static boolean areAllJoinVarsAreCertain(Set<org.apache.jena.sparql.core.Var> varsInQuery, ExpectedVariables inputVars) Returnstrueif the given set of variables does not overlap with the possible-variables set of the givenExpectedVariables. -
_process
protected void _process(SolutionMapping inputSolMap, IntermediateResultElementSink sink, ExecutionContext execCxt) throws ExecOpExecutionException Description copied from class:UnaryExecutableOpBaseImplementations of this function need to process the given solution mapping as input and send the produced result elements (if any) to the given sink. If an exception occurs while processing the solution mapping, then this exception needs to be thrown.- Specified by:
_processin classUnaryExecutableOpBase- Throws:
ExecOpExecutionException
-
_processJoinableInput
protected void _processJoinableInput(SolutionMapping inputSolMap, org.apache.jena.sparql.engine.binding.Binding inputSolMapRestricted, IntermediateResultElementSink sink, ExecutionContext execCxt) throws ExecOpExecutionException Makes sure that the given solution mapping will be considered for the next bind-join request, and performs that request if enough solution mappings have been accumulated.- Parameters:
inputSolMap- - the solution mapping to be considered; at this point, we assume that this solution mapping covers at least one join variable and does not assign a blank node to any of the join variablesinputSolMapRestricted- - a version of inputSolMap that is restricted to the join variables- Throws:
ExecOpExecutionException
-
performRequestAndHandleResponse
protected void performRequestAndHandleResponse(IntermediateResultElementSink sink, ExecutionContext execCxt) throws ExecOpExecutionException - Throws:
ExecOpExecutionException
-
alreadyCovered
protected boolean alreadyCovered(org.apache.jena.sparql.engine.binding.Binding inputSolMapRestricted) -
createMySink
protected BaseForExecOpSequentialBindJoin<QueryType,MemberType>.MyIntermediateResultElementSink createMySink() -
consumeMySink
protected void consumeMySink(BaseForExecOpSequentialBindJoin<QueryType, MemberType>.MyIntermediateResultElementSink mySink, IntermediateResultElementSink outputSink) -
_concludeExecution
protected void _concludeExecution(IntermediateResultElementSink sink, ExecutionContext execCxt) throws ExecOpExecutionException Description copied from class:UnaryExecutableOpBaseImplementations of this function need to conclude the execution of this operator and send the remaining result elements (if any) to the given sink. If an exception occurs during this process, then this exception needs to be thrown.- Specified by:
_concludeExecutionin classUnaryExecutableOpBase- Throws:
ExecOpExecutionException
-
reduceRequestBlockSize
protected boolean reduceRequestBlockSize()ReducesrequestBlockSizeto its current value divided by 2 if the resulting value would still be greater or equal tominimumRequestBlockSize. In this case, this function returnstrue. Otherwise, the function returnsfalsewithout reducingrequestBlockSize. -
createExecutableReqOp
protected abstract NullaryExecutableOp createExecutableReqOp(Set<org.apache.jena.sparql.engine.binding.Binding> solMaps) Implementations of this function should create an executable operator that can perform a bind join request in which the query of this bind join operator is combined with the given solution mappings. Implementations can assume that the given solution mappings are already restricted to contain bindings only for the join variables, that none of the given solution mappings contains blank nodes, that none of the given solution mappings is the empty solution mapping, and that the given set of solution mappings is duplicate free and nonempty. The operator created by this function should throw exceptions instead of collecting them. -
resetStats
public void resetStats()- Specified by:
resetStatsin interfaceStatsProvider- Overrides:
resetStatsin classUnaryExecutableOpBase
-
createStats
- Overrides:
createStatsin classUnaryExecutableOpBase
-
switchToFullRetrievalMode
Performs a request to retrieve all solution mappings for the query of this operator (seecreateExecutableReqOpForAll()) and puts the retrieved solution mappings intofullResult.- Throws:
ExecOpExecutionException
-
joinInFullRetrievalMode
protected void joinInFullRetrievalMode(Iterable<SolutionMapping> batchOfSolMaps, IntermediateResultElementSink sink) -
joinInFullRetrievalMode
protected void joinInFullRetrievalMode(SolutionMapping inputSolMap, IntermediateResultElementSink sink) -
createExecutableReqOpForAll
Implementations of this function should create an executable operator that can perform a request to retrieve all solution mappings for the query of this operator (i.e., not a bind-join request). The operator created by this function should throws exceptions instead of collecting them.
-