java.lang.Object
org.elasticsearch.compute.operator.topn.TopNOperator
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,Operator,org.elasticsearch.core.Releasable
An operator that sorts "rows" of values by encoding the values to sort on, as bytes (using BytesRef). Each data type is encoded
in a specific way, defined by methods of a TopNEncoder. All the values used to sort a specific row (think of column/block 3
and column/block 6) are converted/encoded in a byte array and the concatenated bytes are all compared in bulk.
For now, the only values that have a special "treatment" when it comes to encoding are the text-based ones (text, keyword, ip, version).
For each "special" encoding there is should be new TopNEncoder implementation. See
TopNEncoder.UTF8 for
encoding regular "text" and "keyword" data types. See LocalExecutionPlanner for which data type uses which encoder.
This Operator will not be able to sort binary values (encoded as BytesRef) because the bytes used as separator and "null"s can appear
as valid bytes inside a binary value.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final recordstatic final recordNested classes/interfaces inherited from interface org.elasticsearch.compute.operator.Operator
Operator.OperatorFactory, Operator.Status -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields inherited from interface org.elasticsearch.compute.operator.Operator
MIN_TARGET_PAGE_SIZE, NOT_BLOCKED, TARGET_PAGE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionTopNOperator(BlockFactory blockFactory, CircuitBreaker breaker, int topCount, List<ElementType> elementTypes, List<TopNEncoder> encoders, List<TopNOperator.SortOrder> sortOrders, int maxPageRows, long jumboPageBytes, TopNOperator.InputOrdering inputOrdering, SharedMinCompetitive.Supplier minCompetitiveSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoidadds an input page to the operator.booleanReturns true if the operator can produce more output pages without requiring additional input pages.voidclose()notifies the operator that it won't be used anymore (i.e.voidfinish()notifies the operator that it won't receive any more input pagesreturns non-null if output page available.booleanwhether the operator has finished processing all input pages and made the corresponding output pages availablebooleanwhether the given operator can accept more input pageslongstatus()The status of the operator.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Constructor Details
-
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 -
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
-
canProduceMoreDataWithoutExtraInput
public boolean canProduceMoreDataWithoutExtraInput()Description copied from interface:OperatorReturns 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 returntrue:- Operators with internal buffers (e.g.,
AsyncOperatorwith pending results) - Operators processing a single input page into multiple output pages
- Aggregation operators that buffer partial results
- Specified by:
canProduceMoreDataWithoutExtraInputin interfaceOperator- Returns:
trueif the operator has buffered data that can produce output,falseotherwise
- Operators with internal buffers (e.g.,
-
getOutput
Description copied from interface:Operatorreturns non-null if output page available. Only called when isFinished() == false -
close
public 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 -
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
status
Description copied from interface:OperatorThe status of the operator. -
toString
-