Package io.trino.operator
Interface WorkProcessor<T>
public interface WorkProcessor<T>
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic final classstatic interfacestatic final class -
Method Summary
Modifier and TypeMethodDescriptiondefault WorkProcessor<T> static <T> WorkProcessor<T> create(WorkProcessor.Process<T> process) CreatesWorkProcessorfromWorkProcessor.Process.default WorkProcessor<T> finishWhen(BooleanSupplier finishSignal) default <R> WorkProcessor<R> flatMap(Function<T, WorkProcessor<R>> mapper) static <T> WorkProcessor<T> flatten(WorkProcessor<WorkProcessor<T>> processor) default <R> WorkProcessor<R> flatTransform(WorkProcessor.Transformation<T, WorkProcessor<R>> transformation) FlattensWorkProcessors returned by transformation.static <T> WorkProcessor<T> fromIterable(Iterable<T> iterable) static <T> WorkProcessor<T> fromIterator(Iterator<T> iterator) com.google.common.util.concurrent.ListenableFuture<Void> Get the result once the unit of work is done and the processor hasn't finished.booleanbooleaniterator()ConvertsWorkProcessorinto anIterator.default <R> WorkProcessor<R> static <T> WorkProcessor<T> mergeSorted(Iterable<WorkProcessor<T>> processorIterable, Comparator<T> comparator) static <T> WorkProcessor<T> of(T... elements) booleanprocess()Call the method to progress the work.default <R> WorkProcessor<R> transform(WorkProcessor.Transformation<T, R> transformation) TransformsWorkProcessorusingWorkProcessor.Transformation.default <R> WorkProcessor<R> transformProcessor(Function<WorkProcessor<T>, WorkProcessor<R>> transformation) default WorkProcessor<T> withProcessEntryMonitor(Runnable monitor) default WorkProcessor<T> default WorkProcessor<T> yielding(BooleanSupplier yieldSignal) MakesWorkProcessoryield when givenyieldSignalis set.ConvertsWorkProcessorinto an yieldingIterator.
-
Method Details
-
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
MakesWorkProcessoryield when givenyieldSignalis set. The processor is guaranteed to progress computations on subsequentprocess()calls even ifyieldSignalis permanently on. -
blocking
default WorkProcessor<T> blocking(Supplier<com.google.common.util.concurrent.ListenableFuture<Void>> futureSupplier) -
withProcessEntryMonitor
-
withProcessStateMonitor
-
finishWhen
-
flatMap
-
map
-
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
TransformsWorkProcessorusingWorkProcessor.Transformation.WorkProcessor.Transformationinstance will be dereferenced immediately afterWorkProcessoris exhausted. -
transformProcessor
default <R> WorkProcessor<R> transformProcessor(Function<WorkProcessor<T>, WorkProcessor<R>> transformation) -
iterator
ConvertsWorkProcessorinto anIterator. The iterator will throwIllegalStateExceptionwhen underlyingWorkProcessoryields or becomes blocked.WorkProcessorinstance will be dereferenced immediately after iterator is finished. -
yieldingIterator
ConvertsWorkProcessorinto an yieldingIterator. The iterator will throwIllegalStateExceptionwhen underlyingWorkProcessorbecomes blocked.WorkProcessorinstance will be dereferenced immediately after iterator is exhausted. -
flatten
-
of
-
fromIterable
-
fromIterator
-
create
CreatesWorkProcessorfromWorkProcessor.Process.WorkProcessor.Processinstance will be dereferenced immediately afterWorkProcessoris finished. -
mergeSorted
static <T> WorkProcessor<T> mergeSorted(Iterable<WorkProcessor<T>> processorIterable, Comparator<T> comparator)
-