Class ParallelExecutorBase<T>
java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>
org.eclipse.rdf4j.common.iteration.LookAheadIteration<T,QueryEvaluationException>
org.eclipse.rdf4j.federated.evaluation.concurrent.ParallelExecutorBase<T>
- Type Parameters:
T-
- All Implemented Interfaces:
AutoCloseable,Runnable,CloseableIteration<T,,QueryEvaluationException> Iteration<T,,QueryEvaluationException> ParallelExecutor<T>
- Direct Known Subclasses:
JoinExecutorBase,UnionExecutorBase
public abstract class ParallelExecutorBase<T>
extends LookAheadIteration<T,QueryEvaluationException>
implements ParallelExecutor<T>
Base class for common parallel executors such as
JoinExecutorBase and UnionExecutorBase.- Author:
- Andreas Schwarte
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Threadprotected final longprotected booleanprotected static final org.slf4j.Loggerprotected static final AtomicLongprotected final QueryInfoprotected CloseableIteration<T,QueryEvaluationException> protected FedXQueueCursor<T>protected final FederationEvalStrategy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidHandle the result appropriately, e.g.protected voidChecks whether the query execution has run into a timeout.voiddone()Inform the controlling instance that some job is done from a different thread.protected Stringprotected StringgetId()Gets the next element.Return the query info of the associated queryvoidCalled byAbstractCloseableIteration.close()when it is called for the first time.booleanReturn true if this executor is finished or abortedprotected abstract voidPerform the parallel execution.final voidrun()voidToss some exception to the controlling instancetoString()Methods inherited from class org.eclipse.rdf4j.common.iteration.LookAheadIteration
hasNext, next, removeMethods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
stream
-
Field Details
-
log
protected static final org.slf4j.Logger log -
NEXT_EXECUTOR_ID
-
strategy
-
executorId
protected final long executorId -
queryInfo
-
evaluationThread
-
rightQueue
-
rightIter
-
finished
protected volatile boolean finished
-
-
Constructor Details
-
ParallelExecutorBase
- Throws:
QueryEvaluationException
-
-
Method Details
-
run
public final void run() -
performExecution
Perform the parallel execution.Note that this method must block until the execution is completed.
- Throws:
Exception
-
addResult
Description copied from interface:ParallelExecutorHandle the result appropriately, e.g. add it to the result iteration. Take care for synchronization in a multithreaded environment- Specified by:
addResultin interfaceParallelExecutor<T>
-
done
public void done()Description copied from interface:ParallelExecutorInform the controlling instance that some job is done from a different thread. In most cases this is a no-op.- Specified by:
donein interfaceParallelExecutor<T>
-
toss
Description copied from interface:ParallelExecutorToss some exception to the controlling instance- Specified by:
tossin interfaceParallelExecutor<T>
-
getNextElement
Description copied from class:LookAheadIterationGets the next element. Subclasses should implement this method so that it returns the next element.- Specified by:
getNextElementin classLookAheadIteration<T,QueryEvaluationException> - Returns:
- The next element, or null if no more elements are available.
- Throws:
QueryEvaluationException
-
checkTimeout
Checks whether the query execution has run into a timeout. If so, aQueryInterruptedExceptionis thrown.- Throws:
QueryInterruptedException
-
handleClose
Description copied from class:AbstractCloseableIterationCalled byAbstractCloseableIteration.close()when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.- Overrides:
handleClosein classLookAheadIteration<T,QueryEvaluationException> - Throws:
QueryEvaluationException
-
isFinished
public boolean isFinished()Return true if this executor is finished or aborted- Specified by:
isFinishedin interfaceParallelExecutor<T>- Returns:
- whether the executor is finished
-
getQueryInfo
Description copied from interface:ParallelExecutorReturn the query info of the associated query- Specified by:
getQueryInfoin interfaceParallelExecutor<T>- Returns:
- the query info
-
getId
- Returns:
- a unique identifier of this execution
-
getDisplayId
-
getExecutorType
- Returns:
- the executor type, e.g. "Join". Default "Executor"
-
toString
-