Module org.elasticsearch.compute
Class AsyncOperator<Fetched>
java.lang.Object
org.elasticsearch.compute.operator.AsyncOperator<Fetched>
- All Implemented Interfaces:
Closeable,AutoCloseable,Operator,org.elasticsearch.core.Releasable
AsyncOperator performs an external computation specified in
performAsync(Page, ActionListener). This operator acts as a client
to reduce communication overhead and fetches a Fetched at a time.
It's the responsibility of subclasses to transform that Fetched into
output.- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.compute.operator.Operator
Operator.OperatorFactory -
Field Summary
Fields inherited from interface org.elasticsearch.compute.operator.Operator
MIN_TARGET_PAGE_SIZE, NOT_BLOCKED, TARGET_PAGE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionAsyncOperator(DriverContext driverContext, int maxOutstandingRequests) Create an operator that performs an external computation -
Method Summary
Modifier and TypeMethodDescriptionvoidadds an input page to the operator.final voidclose()notifies the operator that it won't be used anymore (i.e.protected abstract voiddoClose()final FetchedGet aAsyncOperatorfrom the buffer.voidfinish()notifies the operator that it won't receive any more input pagesAn operator can be blocked on some action (e.g.booleanwhether the operator has finished processing all input pages and made the corresponding output pages availablebooleanwhether the given operator can accept more input pagesprotected abstract voidperformAsync(Page inputPage, ActionListener<Fetched> listener) Performs an external computation and notify the listener when the result is ready.protected abstract voidreleaseFetchedOnAnyThread(Fetched result) protected static voidreleasePageOnAnyThread(Page page) final Operator.Statusstatus()The status of the operator.protected Operator.Statusstatus(long receivedPages, long completedPages, long totalTimeInMillis)
-
Constructor Details
-
AsyncOperator
Create an operator that performs an external computation- Parameters:
maxOutstandingRequests- the maximum number of outstanding requests
-
-
Method Details
-
needsInput
public boolean needsInput()Description copied from interface:Operatorwhether the given operator can accept more input pages- Specified by:
needsInputin interfaceOperator
-
addInput
Description copied from interface:Operatoradds an input page to the operator. only called when needsInput() == true and isFinished() == false -
releasePageOnAnyThread
-
releaseFetchedOnAnyThread
-
performAsync
Performs an external computation and notify the listener when the result is ready.- Parameters:
inputPage- the input pagelistener- the listener
-
doClose
protected abstract void doClose() -
close
public final void close()Description copied from interface:Operatornotifies the operator that it won't be used anymore (i.e. none of the other methods called), and its resources can be cleaned up -
finish
public void finish()Description copied from interface:Operatornotifies the operator that it won't receive any more input pages -
isFinished
public boolean isFinished()Description copied from interface:Operatorwhether the operator has finished processing all input pages and made the corresponding output pages available- Specified by:
isFinishedin interfaceOperator
-
fetchFromBuffer
Get aAsyncOperatorfrom the buffer.- Returns:
- a result if one is ready or
nullif none are available.
-
isBlocked
Description copied from interface:OperatorAn operator can be blocked on some action (e.g. waiting for some resources to become available). If so, it returns a future that completes when the operator becomes unblocked. If the operator is not blocked, this method returnsOperator.NOT_BLOCKEDwhich is an already completed future. -
status
Description copied from interface:OperatorThe status of the operator. -
status
-