Class ReturnOrAwait<T>

java.lang.Object
org.apache.druid.frame.processor.ReturnOrAwait<T>

public class ReturnOrAwait<T> extends Object
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 Details

    • runAgain

      public static <T> ReturnOrAwait<T> runAgain()
      Wait for nothing; that is: run again as soon as possible.
    • awaitAll

      public static <T> ReturnOrAwait<T> awaitAll(it.unimi.dsi.fastutil.ints.IntSet await)
      Wait for all provided channels to become readable (or finished). Numbers in this set correspond to positions in the FrameProcessor.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

      public static <T> ReturnOrAwait<T> awaitAll(int count)
      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

      public static <T> ReturnOrAwait<T> awaitAny(it.unimi.dsi.fastutil.ints.IntSet await)
      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 the FrameProcessor.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

      public static <T> ReturnOrAwait<T> returnObject(T o)
      Return a result.
    • value

      @Nullable public T value()
      The returned result. Valid if isReturn() is true.
    • awaitableChannels

      public it.unimi.dsi.fastutil.ints.IntSet awaitableChannels()
      The set of channels the processors wants to wait for. Valid if isAwait() is true. Numbers in this set correspond to positions in the FrameProcessor.inputChannels() list.
    • awaitableFutures

      public Collection<com.google.common.util.concurrent.ListenableFuture<?>> awaitableFutures()
    • isReturn

      public boolean isReturn()
      Whether the processor has returned a value. This is the opposite of isAwait().
    • isAwait

      public boolean isAwait()
      Whether the processor wants to be scheduled again. This is the opposite of isReturn().
    • 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, and isAwaitAllChannels().
    • isAwaitAllChannels

      public boolean isAwaitAllChannels()
      Whether the processor wants to wait for all channels in awaitableChannels() (true), or any channel (false)
    • toString

      public String toString()
      Overrides:
      toString in class Object