Class SourceOperator

java.lang.Object
org.elasticsearch.compute.operator.SourceOperator
All Implemented Interfaces:
Closeable, AutoCloseable, Operator, org.elasticsearch.core.Releasable
Direct Known Subclasses:
EnrichQuerySourceOperator, ExchangeSourceOperator, LocalSourceOperator, LuceneOperator

public abstract class SourceOperator extends Object implements Operator
A source operator - produces output, accepts no input.
  • Constructor Details

    • SourceOperator

      public SourceOperator()
  • Method Details

    • needsInput

      public final boolean needsInput()
      A source operator needs no input - unconditionally returns false.
      Specified by:
      needsInput in interface Operator
      Returns:
      false
    • addInput

      public final void addInput(Page page)
      A source operator does not accept input - unconditionally throws UnsupportedOperationException.
      Specified by:
      addInput in interface Operator
      Parameters:
      page - a page
    • canProduceMoreDataWithoutExtraInput

      public boolean canProduceMoreDataWithoutExtraInput()
      Description copied from interface: Operator
      Returns true if the operator can produce more output pages without requiring additional input pages. This is useful for operators that buffer data or have internal state that can produce multiple output pages.

      Operators that do not buffer data should return false - they cannot produce pages out of thin air. Examples of operators that may return true:

      • Operators with internal buffers (e.g., AsyncOperator with pending results)
      • Operators processing a single input page into multiple output pages
      • Aggregation operators that buffer partial results
      Specified by:
      canProduceMoreDataWithoutExtraInput in interface Operator
      Returns:
      true if the operator has buffered data that can produce output, false otherwise
    • shardLoadDelta

      protected List<SourceOperator.ShardLoad> shardLoadDelta(long now)
      Returns a snapshot of shard load accumulated since the previous invocation.

      This method is meant to be overridden by SourceOperator implementations that can attribute produced pages to shards or indices.

      The snapshot represents a delta: implementations must reset their internal counters after the snapshot is taken so that each invocation reports only the load observed since the last call.

      Source operators that do not operate on shards or indices can ignore this mechanism and rely on the default implementation, which returns an empty list.

      Returns:
      list of per-shard load since the last call