Package io.trino.operator
Interface WorkProcessor<T>
-
public interface WorkProcessor<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceWorkProcessor.Process<T>static classWorkProcessor.ProcessState<T>static interfaceWorkProcessor.Transformation<T,R>static classWorkProcessor.TransformationState<T>
-
Method Summary
-
-
-
Method Detail
-
process
boolean process()
Call the method to progress the work. When this method returns true then the processor is either finished or has a result available viagetResult(). When this method returns false then the processor is either blocked or has yielded.
-
isBlocked
boolean isBlocked()
-
getBlockedFuture
com.google.common.util.concurrent.ListenableFuture<Void> getBlockedFuture()
- Returns:
- a blocked future when
isBlocked()returned true.
-
isFinished
boolean isFinished()
- Returns:
- true if the processor is finished. No more results are expected.
-
getResult
T getResult()
Get the result once the unit of work is done and the processor hasn't finished.
-
yielding
default WorkProcessor<T> yielding(BooleanSupplier yieldSignal)
MakesWorkProcessoryield when givenyieldSignalis set. The processor is guaranteed to progress computations on subsequentprocess()calls even ifyieldSignalis permanently on.
-
withProcessEntryMonitor
default WorkProcessor<T> withProcessEntryMonitor(Runnable monitor)
-
withProcessStateMonitor
default WorkProcessor<T> withProcessStateMonitor(Consumer<WorkProcessor.ProcessState<T>> monitor)
-
finishWhen
default WorkProcessor<T> finishWhen(BooleanSupplier finishSignal)
-
flatMap
default <R> WorkProcessor<R> flatMap(Function<T,WorkProcessor<R>> mapper)
-
map
default <R> WorkProcessor<R> map(Function<T,R> mapper)
-
flatTransform
default <R> WorkProcessor<R> flatTransform(WorkProcessor.Transformation<T,WorkProcessor<R>> transformation)
FlattensWorkProcessors returned by transformation. EachWorkProcessorproduced by transformation will be fully consumed before transformation is called again to produce more processors.
-
transform
default <R> WorkProcessor<R> transform(WorkProcessor.Transformation<T,R> transformation)
TransformsWorkProcessorusingWorkProcessor.Transformation.WorkProcessor.Transformationinstance will be dereferenced immediately afterWorkProcessoris exhausted.
-
transformProcessor
default <R> WorkProcessor<R> transformProcessor(Function<WorkProcessor<T>,WorkProcessor<R>> transformation)
-
iterator
default Iterator<T> iterator()
ConvertsWorkProcessorinto anIterator. The iterator will throwIllegalStateExceptionwhen underlyingWorkProcessoryields or becomes blocked.WorkProcessorinstance will be dereferenced immediately after iterator is finished.
-
yieldingIterator
default Iterator<Optional<T>> yieldingIterator()
ConvertsWorkProcessorinto an yieldingIterator. The iterator will throwIllegalStateExceptionwhen underlyingWorkProcessorbecomes blocked.WorkProcessorinstance will be dereferenced immediately after iterator is exhausted.
-
flatten
static <T> WorkProcessor<T> flatten(WorkProcessor<WorkProcessor<T>> processor)
-
of
@SafeVarargs static <T> WorkProcessor<T> of(T... elements)
-
fromIterable
static <T> WorkProcessor<T> fromIterable(Iterable<T> iterable)
-
fromIterator
static <T> WorkProcessor<T> fromIterator(Iterator<T> iterator)
-
create
static <T> WorkProcessor<T> create(WorkProcessor.Process<T> process)
CreatesWorkProcessorfromWorkProcessor.Process.WorkProcessor.Processinstance will be dereferenced immediately afterWorkProcessoris finished.
-
mergeSorted
static <T> WorkProcessor<T> mergeSorted(Iterable<WorkProcessor<T>> processorIterable, Comparator<T> comparator)
-
-