Package org.apache.druid.frame.processor
Class ReturnOrAwait<T>
java.lang.Object
org.apache.druid.frame.processor.ReturnOrAwait<T>
Instances of this class are returned by
FrameProcessor.runIncrementally(it.unimi.dsi.fastutil.ints.IntSet), and are used by
FrameProcessorExecutor to manage execution.
An instance can be a "return" with a result, which means that the FrameProcessor is done working.
In this case isReturn() is true and value() contains the result.
An instance can also be an "await", which means that the FrameProcessor wants to be scheduled again
in the future. In this case isAwait() is true, and *either* hasAwaitableChannels() or
hasAwaitableFutures() is true.-
Method Summary
Modifier and TypeMethodDescriptionit.unimi.dsi.fastutil.ints.IntSetThe set of channels the processors wants to wait for.Collection<com.google.common.util.concurrent.ListenableFuture<?>> static <T> ReturnOrAwait<T> awaitAll(int count) Wait for all of a certain number of channels.static <T> ReturnOrAwait<T> awaitAll(it.unimi.dsi.fastutil.ints.IntSet await) Wait for all provided channels to become readable (or finished).static <T> ReturnOrAwait<T> awaitAllFutures(Collection<com.google.common.util.concurrent.ListenableFuture<?>> futures) Wait for all of the provided futures.static <T> ReturnOrAwait<T> awaitAny(it.unimi.dsi.fastutil.ints.IntSet await) Wait for any of the provided channels to become readable (or finished).booleanWhether the processor wants to wait for a set of channels.booleanWhether the processor wants to wait for a set of futures.booleanisAwait()Whether the processor wants to be scheduled again.booleanWhether the processor wants to wait for all channels inawaitableChannels()(true), or any channel (false)booleanisReturn()Whether the processor has returned a value.static <T> ReturnOrAwait<T> returnObject(T o) Return a result.static <T> ReturnOrAwait<T> runAgain()Wait for nothing; that is: run again as soon as possible.toString()value()The returned result.
-
Method Details
-
runAgain
Wait for nothing; that is: run again as soon as possible. -
awaitAll
Wait for all provided channels to become readable (or finished). Numbers in this set correspond to positions in theFrameProcessor.inputChannels()list. It is OK to pass in a mutable set, because this method does not modify the set or retain a reference to it. -
awaitAll
Wait for all of a certain number of channels. -
awaitAllFutures
public static <T> ReturnOrAwait<T> awaitAllFutures(Collection<com.google.common.util.concurrent.ListenableFuture<?>> futures) Wait for all of the provided futures. -
awaitAny
Wait for any of the provided channels to become readable (or finished). When using this, callers should consider removing any fully-processed and finished channels from the await-set, because if any channels in the await-set are finished, the processor will run again immediately. Numbers in this set correspond to positions in theFrameProcessor.inputChannels()list. It is OK to pass in a mutable set, because this method does not modify the set or retain a reference to it. -
returnObject
Return a result. -
value
The returned result. Valid ifisReturn()is true. -
awaitableChannels
public it.unimi.dsi.fastutil.ints.IntSet awaitableChannels()The set of channels the processors wants to wait for. Valid ifisAwait()is true. Numbers in this set correspond to positions in theFrameProcessor.inputChannels()list. -
awaitableFutures
-
isReturn
public boolean isReturn()Whether the processor has returned a value. This is the opposite ofisAwait(). -
isAwait
public boolean isAwait()Whether the processor wants to be scheduled again. This is the opposite ofisReturn(). -
hasAwaitableFutures
public boolean hasAwaitableFutures()Whether the processor wants to wait for a set of futures. If true,awaitableFutures()contains the set of futures to wait for. -
hasAwaitableChannels
public boolean hasAwaitableChannels()Whether the processor wants to wait for a set of channels. If true,awaitableChannels()contains the set of channels to wait for, andisAwaitAllChannels(). -
isAwaitAllChannels
public boolean isAwaitAllChannels()Whether the processor wants to wait for all channels inawaitableChannels()(true), or any channel (false) -
toString
-