Class RerankOperatorOutputBuilder

java.lang.Object
org.elasticsearch.xpack.esql.inference.rerank.RerankOperatorOutputBuilder
All Implemented Interfaces:
Closeable, AutoCloseable, org.elasticsearch.core.Releasable, InferenceOperator.OutputBuilder

public class RerankOperatorOutputBuilder extends Object implements InferenceOperator.OutputBuilder
Builds the output page for the RerankOperator by adding * reranked relevance scores into the specified score channel of the input page.
  • Constructor Details

    • RerankOperatorOutputBuilder

      public RerankOperatorOutputBuilder(DoubleBlock.Builder scoreBlockBuilder, Page inputPage, int scoreChannel)
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.elasticsearch.core.Releasable
    • buildOutput

      public Page buildOutput()
      Constructs a new output Page which contains all original blocks from the input page, with the reranked scores inserted at scoreChannel.
      Specified by:
      buildOutput in interface InferenceOperator.OutputBuilder
      Returns:
      The constructed output page.
    • addInferenceResponse

      public void addInferenceResponse(InferenceAction.Response inferenceResponse)
      Extracts the ranked document results from the inference response and appends their relevance scores to the score block builder.

      If the response is not of type ChatCompletionResults an IllegalStateException is thrown.

      The responses must be added in the same order as the corresponding inference requests were generated. Failing to preserve order may lead to incorrect or misaligned output rows.

      Specified by:
      addInferenceResponse in interface InferenceOperator.OutputBuilder
      Parameters:
      inferenceResponse - The inference response to include.