Interface ExchangeSource

All Superinterfaces:
AutoCloseable, Closeable

@ThreadSafe public interface ExchangeSource extends Closeable
  • Field Details

  • Method Details

    • addSourceHandles

      void addSourceHandles(List<ExchangeSourceHandle> handles)
      Add more ExchangeSourceHandle's to be read by the ExchangeSource.
      Parameters:
      handles - list of ExchangeSourceHandle's describing what exchange data to read. The full list of handles is returned by ExchangeSourceHandleSource. The coordinator decides what items from that list should be handled by what task and creates sub-lists that are further getting sent to a worker to be read. The handles list may contain ExchangeSourceHandle's created by more than a single Exchange.
    • noMoreSourceHandles

      void noMoreSourceHandles()
      Notify ExchangeSource that no more ExchangeSourceHandle's will be added with the addSourceHandles(List) method.
    • setOutputSelector

      void setOutputSelector(ExchangeSourceOutputSelector selector)
      Called by the engine to provide information about what source task output must be included and what must be skipped.

      This method can be called multiple times and out of order. Only a newest version (see ExchangeSourceOutputSelector.getVersion()) must be taken into account. Updates with an older version must be ignored.

      The information provided by the ExchangeSourceOutputSelector is incremental and decisions for some partitions could be missing. The implementation is free to speculate.

      The final selector is guaranteed to contain a decision for each source partition (see ExchangeSourceOutputSelector.isFinal()). If decision is made for a given partition in some version the decision is guaranteed not to change in newer versions.

    • isBlocked

      CompletableFuture<Void> isBlocked()
      Returns a future that will be completed when the exchange source becomes unblocked. If the exchange source is not blocked, this method should return NOT_BLOCKED
    • isFinished

      boolean isFinished()
      Once isFinished returns true, read() will never return a non-null result
    • read

      @Nullable io.airlift.slice.Slice read()
      Gets the next chunk of data. This method is allowed to return null.

      The engine will keep calling this method until isFinished() returns true

      Returns:
      data written to an exchange using ExchangeSink.add(int, Slice). The slice is always returned as a whole as written (the exchange does not split and does not merge slices).
    • getMemoryUsage

      long getMemoryUsage()
      Get the total memory that needs to be reserved in the memory pool. This memory should include any buffers, etc. that are used for reading data
    • getMetrics

      default Optional<Metrics> getMetrics()
      Get metrics describing ExchangeSource. Metrics will be exposed via matching ExchangeOperator description.
    • close

      void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable