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 classprotected static enum - 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<SolutionMapping> protected final ExecutionContextprotected 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 ExecutableOperatorgetStats()//////////////////////////////////////////////// Stats-related code ////////////////////////////////////////////////protected PushBasedPlanThreadImplBase.StatusbooleanReturns true if the execution of this task has failed with an exception.boolean//////////////////////////////////////////////// Methods to be called by the consuming thread ////////////////////////////////////////////////booleanReturns 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).booleanReturns 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 voidvoidfinal voidrun()//////////////////////////////////////////////// Methods that implement the core functionality of this producing thread ////////////////////////////////////////////////intsend(Iterable<SolutionMapping> it) Consumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)for everySolutionMappingobtained from the iterator, and returns the number of solution mappings obtained from the iterator.intsend(Iterator<SolutionMapping> it) Consumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)for everySolutionMappingobtained from the iterator, and returns the number of solution mappings obtained from the iterator.voidsend(SolutionMapping element) //////////////////////////////////////////////// IntermediateResultElementSink for the producing thread ////////////////////////////////////////////////protected voidsetCauseOfFailure(Exception cause) protected voidsetStatus(PushBasedPlanThreadImplBase.Status newStatus) final voidtransferAvailableOutput(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 voidwrapUp(boolean failed, boolean interrupted)  
- 
Field Details
- 
execCxt
 - 
extraConnectors
 - 
availableOutput
 
 - 
 - 
Constructor Details
- 
PushBasedPlanThreadImplBase
 
 - 
 - 
Method Details
- 
addConnectorForAdditionalConsumer
Description copied from interface:PushBasedPlanThreadCan 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, separatePushBasedPlanThreadinstance, 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:
 addConnectorForAdditionalConsumerin 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:
 sendin interfaceIntermediateResultElementSink
 - 
send
Description copied from interface:IntermediateResultElementSinkConsumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)for everySolutionMappingobtained from the iterator, and returns the number of solution mappings obtained from the iterator.- Specified by:
 sendin interfaceIntermediateResultElementSink
 - 
send
Description copied from interface:IntermediateResultElementSinkConsumes the given iterator, callingIntermediateResultElementSink.send(SolutionMapping)for everySolutionMappingobtained from the iterator, and returns the number of solution mappings obtained from the iterator.- Specified by:
 sendin interfaceIntermediateResultElementSink
 - 
hasMoreOutputAvailable
public boolean hasMoreOutputAvailable()//////////////////////////////////////////////// Methods to be called by the consuming thread ////////////////////////////////////////////////- Specified by:
 hasMoreOutputAvailablein interfacePushBasedPlanThread
 - 
transferAvailableOutput
public final void transferAvailableOutput(List<SolutionMapping> transferBuffer) throws ConsumingPushBasedPlanThreadException Description copied from interface:PushBasedPlanThreadThis 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:
 transferAvailableOutputin interfacePushBasedPlanThread- Throws:
 ConsumingPushBasedPlanThreadException
 - 
getStatus
 - 
isRunning
public boolean isRunning()Description copied from interface:PushBasedPlanThreadReturns 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:
 isRunningin interfacePushBasedPlanThread
 - 
isCompleted
public boolean isCompleted()Description copied from interface:PushBasedPlanThreadReturns 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:
 isCompletedin interfacePushBasedPlanThread
 - 
hasFailed
public boolean hasFailed()Description copied from interface:PushBasedPlanThreadReturns 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:
 hasFailedin interfacePushBasedPlanThread
 - 
getCauseOfFailure
Description copied from interface:PushBasedPlanThreadReturns the exception that caused the execution of this task to fail (in casePushBasedPlanThread.hasFailed()istrue).- Specified by:
 getCauseOfFailurein interfacePushBasedPlanThread
 - 
getExceptionsCaughtDuringExecution
 - 
getExecOp
 - 
getStats
//////////////////////////////////////////////// Stats-related code ////////////////////////////////////////////////- Specified by:
 getStatsin interfacePushBasedPlanThread- Specified by:
 getStatsin interfaceStatsProvider
 - 
resetStats
public void resetStats()- Specified by:
 resetStatsin interfaceStatsProvider
 
 -