Class PushBasedPlanThreadImplBase
java.lang.Object
se.liu.ida.hefquin.engine.queryplan.executable.impl.pushbased.PushBasedPlanThreadImplBase
- All Implemented Interfaces:
Runnable
,StatsProvider
,PushBasedPlanThread
,IntermediateResultElementSink
- Direct Known Subclasses:
ConnectorForAdditionalConsumer
,PushBasedPlanThreadImplForBinaryOperator
,PushBasedPlanThreadImplForNaryOperator
,PushBasedPlanThreadImplForNullaryOperator
,PushBasedPlanThreadImplForUnaryOperator
public abstract class PushBasedPlanThreadImplBase
extends Object
implements PushBasedPlanThread, IntermediateResultElementSink
Contains the core part of implementing
PushBasedPlanThread
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
protected static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List
<SolutionMapping> protected final ExecutionContext
protected List
<ConnectorForAdditionalConsumer> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCan be used for cases in which multiple threads consume the output produced by this thread.Returns the exception that caused the execution of this task to fail (in casePushBasedPlanThread.hasFailed()
istrue
).protected abstract ExecutableOperator
getStats()
//////////////////////////////////////////////// Stats-related code ////////////////////////////////////////////////protected PushBasedPlanThreadImplBase.Status
boolean
Returns true if the execution of this task has failed with an exception.boolean
//////////////////////////////////////////////// Methods to be called by the consuming thread ////////////////////////////////////////////////boolean
Returns true if the execution of this task has completed successfully, and returns false if either the execution is still running (in which casePushBasedPlanThread.isRunning()
istrue
) or the execution has been interrupted (in which casePushBasedPlanThread.isRunning()
isfalse
).boolean
Returns true if the execution of this task is currently running; that is, the execution has started and has neither been interrupted nor completed.protected abstract void
void
final void
run()
//////////////////////////////////////////////// Methods that implement the core functionality of this producing thread ////////////////////////////////////////////////int
send
(Iterable<SolutionMapping> it) Consumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)
for everySolutionMapping
obtained from the iterator, and returns the number of solution mappings obtained from the iterator.int
send
(Iterator<SolutionMapping> it) Consumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)
for everySolutionMapping
obtained from the iterator, and returns the number of solution mappings obtained from the iterator.void
send
(SolutionMapping element) //////////////////////////////////////////////// IntermediateResultElementSink for the producing thread ////////////////////////////////////////////////protected void
setCauseOfFailure
(Exception cause) protected void
setStatus
(PushBasedPlanThreadImplBase.Status newStatus) final void
transferAvailableOutput
(List<SolutionMapping> transferBuffer) This function first clears the given list and, then, transfers the currently-available solution mappings produced by this task from an internal buffer to the given list, in the order in which the solution mappings have been produced.protected void
wrapUp
(boolean failed, boolean interrupted)
-
Field Details
-
execCxt
-
extraConnectors
-
availableOutput
-
-
Constructor Details
-
PushBasedPlanThreadImplBase
-
-
Method Details
-
addConnectorForAdditionalConsumer
Description copied from interface:PushBasedPlanThread
Can be used for cases in which multiple threads consume the output produced by this thread. While one of these threads may then consume the output directly (by callingPushBasedPlanThread.transferAvailableOutput(List)
), each of the others must then consume the output via its own, separatePushBasedPlanThread
instance, as set up and returned by this method. Hence, for each of these additional consuming threads, this method needs to be called. This method should be called before starting to consume the output. The use case for this are query plans that are not tree-shaped (but still DAGs), which we may have in particular for union-over-join source assignments where some of the joins have the same request operator as input (perhaps even with a filter operator on top of the request).- Specified by:
addConnectorForAdditionalConsumer
in interfacePushBasedPlanThread
-
run
-
setStatus
-
produceOutput
protected abstract void produceOutput(IntermediateResultElementSink sink) throws ExecOpExecutionException, ConsumingPushBasedPlanThreadException -
setCauseOfFailure
-
wrapUp
protected void wrapUp(boolean failed, boolean interrupted) -
send
//////////////////////////////////////////////// IntermediateResultElementSink for the producing thread ////////////////////////////////////////////////- Specified by:
send
in interfaceIntermediateResultElementSink
-
send
Description copied from interface:IntermediateResultElementSink
Consumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)
for everySolutionMapping
obtained from the iterator, and returns the number of solution mappings obtained from the iterator.- Specified by:
send
in interfaceIntermediateResultElementSink
-
send
Description copied from interface:IntermediateResultElementSink
Consumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)
for everySolutionMapping
obtained from the iterator, and returns the number of solution mappings obtained from the iterator.- Specified by:
send
in interfaceIntermediateResultElementSink
-
hasMoreOutputAvailable
public boolean hasMoreOutputAvailable()//////////////////////////////////////////////// Methods to be called by the consuming thread ////////////////////////////////////////////////- Specified by:
hasMoreOutputAvailable
in interfacePushBasedPlanThread
-
transferAvailableOutput
public final void transferAvailableOutput(List<SolutionMapping> transferBuffer) throws ConsumingPushBasedPlanThreadException Description copied from interface:PushBasedPlanThread
This function first clears the given list and, then, transfers the currently-available solution mappings produced by this task from an internal buffer to the given list, in the order in which the solution mappings have been produced. The internal buffer will thus be empty at the point when this function returns (but further solution mappings may still be produced by this task and placed into the buffer to be available to be transferred at the next call of this function). If the internal buffer is empty at the time when this function is called (i.e., no solution mappings are currently available to be transferred), but the task is still running (seePushBasedPlanThread.isRunning()
) and, thus, more solution mappings may still be produced, then the call of this function causes the calling thread to wait until either more solution mappings have been produced or it has become clear that no more solution mappings can be produced anymore. In the former case, the newly-produced solution mappings are transferred to the given list and the function returns. In the latter case, the function returns directly and, thus, the given list remains empty. Also, in the latter case, after the function has returned,PushBasedPlanThread.isCompleted()
will betrue
. If the function is called after the task has completed or failed, then the function returns directly after clearing the given list (i.e., the list will be empty after the function call). Hence, if the given list is empty after calling this function call, then the function does not need to be called anymore; this task is not going to produce more solution mappings. This function is expected to be called by (and, thus, run in the context of) the thread that consumes the solution mappings produced by this task.- Specified by:
transferAvailableOutput
in interfacePushBasedPlanThread
- Throws:
ConsumingPushBasedPlanThreadException
-
getStatus
-
isRunning
public boolean isRunning()Description copied from interface:PushBasedPlanThread
Returns true if the execution of this task is currently running; that is, the execution has started and has neither been interrupted nor completed.- Specified by:
isRunning
in interfacePushBasedPlanThread
-
isCompleted
public boolean isCompleted()Description copied from interface:PushBasedPlanThread
Returns true if the execution of this task has completed successfully, and returns false if either the execution is still running (in which casePushBasedPlanThread.isRunning()
istrue
) or the execution has been interrupted (in which casePushBasedPlanThread.isRunning()
isfalse
).- Specified by:
isCompleted
in interfacePushBasedPlanThread
-
hasFailed
public boolean hasFailed()Description copied from interface:PushBasedPlanThread
Returns true if the execution of this task has failed with an exception. The exception that caused the failed can be obtained by callingPushBasedPlanThread.getCauseOfFailure()
.- Specified by:
hasFailed
in interfacePushBasedPlanThread
-
getCauseOfFailure
Description copied from interface:PushBasedPlanThread
Returns the exception that caused the execution of this task to fail (in casePushBasedPlanThread.hasFailed()
istrue
).- Specified by:
getCauseOfFailure
in interfacePushBasedPlanThread
-
getExceptionsCaughtDuringExecution
-
getExecOp
-
getStats
//////////////////////////////////////////////// Stats-related code ////////////////////////////////////////////////- Specified by:
getStats
in interfacePushBasedPlanThread
- Specified by:
getStats
in interfaceStatsProvider
-
resetStats
public void resetStats()- Specified by:
resetStats
in interfaceStatsProvider
-