Class BulkInferenceExecutionState

java.lang.Object
org.elasticsearch.xpack.esql.inference.bulk.BulkInferenceExecutionState

public class BulkInferenceExecutionState extends Object
Tracks the state of a bulk inference execution, including sequencing, failure management, and buffering of inference responses for ordered output construction.
  • Constructor Details

    • BulkInferenceExecutionState

      public BulkInferenceExecutionState()
  • Method Details

    • generateSeqNo

      public long generateSeqNo()
      Generates a new unique sequence number for an inference request.
    • getPersistedCheckpoint

      public long getPersistedCheckpoint()
      Returns the highest sequence number marked as persisted, such that all lower sequence numbers have also been marked as persisted.
    • getProcessedCheckpoint

      public long getProcessedCheckpoint()
      Returns the highest sequence number marked as processed, such that all lower sequence numbers have also been marked as processed.
    • getMaxSeqNo

      public long getMaxSeqNo()
      Highest generated sequence number.
    • markSeqNoAsPersisted

      public void markSeqNoAsPersisted(long seqNo)
      Marks an inference response as persisted.
      Parameters:
      seqNo - The corresponding sequence number
    • onInferenceResponse

      public void onInferenceResponse(long seqNo, InferenceAction.Response response)
      Add an inference response to the buffer and marks the corresponding sequence number as processed.
      Parameters:
      seqNo - The sequence number of the inference request.
      response - The inference response.
    • onInferenceException

      public void onInferenceException(long seqNo, Exception e)
      * Handles an exception thrown during inference execution. Records the failure and marks the corresponding sequence number as processed.
      Parameters:
      seqNo - The sequence number of the inference request.
      e - The exception
    • fetchBufferedResponse

      public InferenceAction.Response fetchBufferedResponse(long seqNo)
      Retrieves and removes the buffered response by sequence number.
      Parameters:
      seqNo - The sequence number of the response to fetch.
    • hasFailure

      public boolean hasFailure()
      Returns whether any failure has been recorded during execution.
    • getFailure

      public Exception getFailure()
      Returns the recorded failure, if any.
    • addFailure

      public void addFailure(Exception e)
    • finished

      public boolean finished()
      Indicates whether the entire bulk execution is marked as finished and all responses have been successfully persisted.
    • finish

      public void finish()
      Marks the bulk as finished, indicating that all inference requests have been sent.