Class TopNBatch
java.lang.Object
org.apache.drill.exec.record.AbstractRecordBatch<TopN>
org.apache.drill.exec.physical.impl.TopN.TopNBatch
- All Implemented Interfaces:
AutoCloseable
,Iterable<VectorWrapper<?>>
,CloseableRecordBatch
,RecordBatch
,VectorAccessible
Operator Batch which implements the TopN functionality. It is more efficient
than (sort + limit) since unlike sort it doesn't have to store all the input
data to sort it first and then apply limit on the sorted data. Instead
internally it maintains a priority queue backed by a heap with the size being
same as limit value.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.drill.exec.record.AbstractRecordBatch
AbstractRecordBatch.BatchState
Nested classes/interfaces inherited from interface org.apache.drill.exec.record.RecordBatch
RecordBatch.IterOutcome
-
Field Summary
Fields inherited from class org.apache.drill.exec.record.AbstractRecordBatch
batchStatsContext, container, context, oContext, popConfig, state, stats, unionTypeEnabled
Fields inherited from interface org.apache.drill.exec.record.RecordBatch
MAX_BATCH_ROW_COUNT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
void
close()
static MappingSet
static MappingSet
static PriorityQueue
createNewPriorityQueue
(MappingSet mainMapping, MappingSet leftMapping, MappingSet rightMapping, List<Order.Ordering> orderings, VectorAccessible batch, boolean unionTypeEnabled, boolean codegenDump, int limit, BufferAllocator allocator, BatchSchema.SelectionVectorMode mode, FragmentContext context) static MappingSet
void
dump()
Perform dump of this batch's state to logs.int
Get the number of records.Gets a writable version of this batch.void
Handle schema changes during execution.Methods inherited from class org.apache.drill.exec.record.AbstractRecordBatch
cancel, checkContinue, getContainer, getContext, getOutgoingContainer, getPopConfig, getRecordBatchStatsContext, getSchema, getValueAccessorById, getValueVectorId, isRecordBatchStatsLoggingEnabled, iterator, next, next, next, schemaChangeException, schemaChangeException
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TopNBatch
public TopNBatch(TopN popConfig, FragmentContext context, RecordBatch incoming) throws OutOfMemoryException - Throws:
OutOfMemoryException
-
-
Method Details
-
getRecordCount
public int getRecordCount()Description copied from interface:VectorAccessible
Get the number of records.- Returns:
- number of records
-
getSelectionVector2
- Specified by:
getSelectionVector2
in interfaceVectorAccessible
- Overrides:
getSelectionVector2
in classAbstractRecordBatch<TopN>
-
getSelectionVector4
- Specified by:
getSelectionVector4
in interfaceVectorAccessible
- Overrides:
getSelectionVector4
in classAbstractRecordBatch<TopN>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classAbstractRecordBatch<TopN>
-
buildSchema
public void buildSchema()- Overrides:
buildSchema
in classAbstractRecordBatch<TopN>
-
innerNext
- Specified by:
innerNext
in classAbstractRecordBatch<TopN>
-
createMainMappingSet
-
createLeftMappingSet
-
createRightMappingSet
-
createNewPriorityQueue
public static PriorityQueue createNewPriorityQueue(MappingSet mainMapping, MappingSet leftMapping, MappingSet rightMapping, List<Order.Ordering> orderings, VectorAccessible batch, boolean unionTypeEnabled, boolean codegenDump, int limit, BufferAllocator allocator, BatchSchema.SelectionVectorMode mode, FragmentContext context) -
purgeAndResetPriorityQueue
public void purgeAndResetPriorityQueue()Handle schema changes during execution. 1. Purge existing batches 2. Promote newly created container for new schema. 3. Recreate priority queue and reset with coerced container. -
getWritableBatch
Description copied from interface:RecordBatch
Gets a writable version of this batch. Takes over ownership of existing buffers.- Specified by:
getWritableBatch
in interfaceRecordBatch
- Overrides:
getWritableBatch
in classAbstractRecordBatch<TopN>
-
cancelIncoming
protected void cancelIncoming()- Specified by:
cancelIncoming
in classAbstractRecordBatch<TopN>
-
dump
public void dump()Description copied from interface:RecordBatch
Perform dump of this batch's state to logs.
-