Class InferenceOperator
java.lang.Object
org.elasticsearch.compute.operator.AsyncOperator<InferenceOperator.OngoingInferenceResult>
org.elasticsearch.xpack.esql.inference.InferenceOperator
- All Implemented Interfaces:
Closeable,AutoCloseable,Operator,org.elasticsearch.core.Releasable
- Direct Known Subclasses:
CompletionOperator,RerankOperator,TextEmbeddingOperator
public abstract class InferenceOperator
extends AsyncOperator<InferenceOperator.OngoingInferenceResult>
An abstract asynchronous operator that performs throttled bulk inference execution.
The InferenceOperator integrates with the compute framework and supports throttled bulk execution of inference requests. It
transforms input Page into inference requests, asynchronously executes them, and uses the responses to build a new Page.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classManages the execution of inference requests for a single input page.static final recordRepresents a single inference request with metadata for result building.static interfacestatic final recordRepresents a completed inference response with metadata for result building.static final recordRepresents the result of a bulk inference operation for a single input page.static interfaceNested classes/interfaces inherited from class org.elasticsearch.compute.operator.AsyncOperator
AsyncOperator.StatusNested classes/interfaces inherited from interface org.elasticsearch.compute.operator.Operator
Operator.OperatorFactory -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from interface org.elasticsearch.compute.operator.Operator
MIN_TARGET_PAGE_SIZE, NOT_BLOCKED, TARGET_PAGE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionInferenceOperator(DriverContext driverContext, InferenceService inferenceService, InferenceOperator.BulkInferenceRequestItemIterator.Factory inferenceRequestsFactory, InferenceOperator.OutputBuilder outputBuilder) Constructs a newInferenceOperatorwith default throttling parameters.InferenceOperator(DriverContext driverContext, InferenceService inferenceService, InferenceOperator.BulkInferenceRequestItemIterator.Factory inferenceRequestsFactory, InferenceOperator.OutputBuilder outputBuilder, int maxOutstandingPages, int maxOutstandingInferenceRequests) Constructs a newInferenceOperator. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoClose()protected Stringprotected voidperformAsync(Page input, ActionListener<InferenceOperator.OngoingInferenceResult> listener) protected voidreleaseFetchedOnAnyThread(InferenceOperator.OngoingInferenceResult ongoingInferenceResult) Methods inherited from class org.elasticsearch.compute.operator.AsyncOperator
addInput, canProduceMoreDataWithoutExtraInput, close, fetchFromBuffer, finish, isBlocked, isFinished, needsInput, releasePageOnAnyThread, status, status
-
Field Details
-
DEFAULT_MAX_OUTSTANDING_PAGES
public static final int DEFAULT_MAX_OUTSTANDING_PAGES- See Also:
-
DEFAULT_MAX_OUTSTANDING_REQUESTS
public static final int DEFAULT_MAX_OUTSTANDING_REQUESTS- See Also:
-
-
Constructor Details
-
InferenceOperator
public InferenceOperator(DriverContext driverContext, InferenceService inferenceService, InferenceOperator.BulkInferenceRequestItemIterator.Factory inferenceRequestsFactory, InferenceOperator.OutputBuilder outputBuilder, int maxOutstandingPages, int maxOutstandingInferenceRequests) Constructs a newInferenceOperator.- Parameters:
driverContext- The driver context.inferenceService- The inference service to use for executing inference requests.maxOutstandingPages- The maximum number of pages processed in parallel.maxOutstandingInferenceRequests- The maximum number of inference requests to be run in parallel.
-
InferenceOperator
public InferenceOperator(DriverContext driverContext, InferenceService inferenceService, InferenceOperator.BulkInferenceRequestItemIterator.Factory inferenceRequestsFactory, InferenceOperator.OutputBuilder outputBuilder) Constructs a newInferenceOperatorwith default throttling parameters. Use default max outstanding pages and requests settings.- Parameters:
driverContext- The driver context.inferenceService- The inference service to use for executing inference requests.inferenceRequestsFactory- Factory for creating inference request iterators from input pages.outputBuilder- Builder for converting inference responses into output pages.
-
-
Method Details
-
performAsync
protected void performAsync(Page input, ActionListener<InferenceOperator.OngoingInferenceResult> listener) - Specified by:
performAsyncin classAsyncOperator<InferenceOperator.OngoingInferenceResult>
-
getOutput
-
releaseFetchedOnAnyThread
protected void releaseFetchedOnAnyThread(InferenceOperator.OngoingInferenceResult ongoingInferenceResult) - Specified by:
releaseFetchedOnAnyThreadin classAsyncOperator<InferenceOperator.OngoingInferenceResult>
-
doClose
protected void doClose()- Specified by:
doClosein classAsyncOperator<InferenceOperator.OngoingInferenceResult>
-
inferenceId
-