Class AsyncOperator<Fetched>

java.lang.Object
org.elasticsearch.compute.operator.AsyncOperator<Fetched>
All Implemented Interfaces:
Closeable, AutoCloseable, Operator, org.elasticsearch.core.Releasable

public abstract class AsyncOperator<Fetched> extends Object implements Operator
AsyncOperator performs an external computation specified in performAsync(Page, ActionListener). This operator acts as a client to reduce communication overhead and fetches a Fetched at a time. It's the responsibility of subclasses to transform that Fetched into output.
See Also:
  • Constructor Details

    • AsyncOperator

      public AsyncOperator(DriverContext driverContext, int maxOutstandingRequests)
      Create an operator that performs an external computation
      Parameters:
      maxOutstandingRequests - the maximum number of outstanding requests
  • Method Details

    • needsInput

      public boolean needsInput()
      Description copied from interface: Operator
      whether the given operator can accept more input pages
      Specified by:
      needsInput in interface Operator
    • addInput

      public void addInput(Page input)
      Description copied from interface: Operator
      adds an input page to the operator. only called when needsInput() == true and isFinished() == false
      Specified by:
      addInput in interface Operator
    • releasePageOnAnyThread

      protected static void releasePageOnAnyThread(Page page)
    • releaseFetchedOnAnyThread

      protected abstract void releaseFetchedOnAnyThread(Fetched result)
    • performAsync

      protected abstract void performAsync(Page inputPage, ActionListener<Fetched> listener)
      Performs an external computation and notify the listener when the result is ready.
      Parameters:
      inputPage - the input page
      listener - the listener
    • doClose

      protected abstract void doClose()
    • close

      public final void close()
      Description copied from interface: Operator
      notifies the operator that it won't be used anymore (i.e. none of the other methods called), and its resources can be cleaned up
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Operator
      Specified by:
      close in interface org.elasticsearch.core.Releasable
    • finish

      public void finish()
      Description copied from interface: Operator
      notifies the operator that it won't receive any more input pages
      Specified by:
      finish in interface Operator
    • isFinished

      public boolean isFinished()
      Description copied from interface: Operator
      whether the operator has finished processing all input pages and made the corresponding output pages available
      Specified by:
      isFinished in interface Operator
    • fetchFromBuffer

      public final Fetched fetchFromBuffer()
      Get a AsyncOperator from the buffer.
      Returns:
      a result if one is ready or null if none are available.
    • isBlocked

      public IsBlockedResult isBlocked()
      Description copied from interface: Operator
      An operator can be blocked on some action (e.g. waiting for some resources to become available). If so, it returns a future that completes when the operator becomes unblocked. If the operator is not blocked, this method returns Operator.NOT_BLOCKED which is an already completed future.
      Specified by:
      isBlocked in interface Operator
    • status

      public final Operator.Status status()
      Description copied from interface: Operator
      The status of the operator.
      Specified by:
      status in interface Operator
    • status

      protected Operator.Status status(long receivedPages, long completedPages, long totalTimeInMillis)