Package io.trino.operator
Class GroupedTopNRowNumberAccumulator
java.lang.Object
io.trino.operator.GroupedTopNRowNumberAccumulator
Memory Layout:
+--------------------+ +--------------+
|GroupIdToHeapBuffer | |HeapNodeBuffer|
+--------------------+ +--------------+
Group1+->+RootNodeIndex1+-------->+RowID1 |
|RootNodeIndex2 | |LeftChild1+-----+
|... | |RightChild1 | |
+--------------------+ |RowID2 <-----+
|HeapSize1 | |LeftChild2 |
|HeapSize2 | |RightChild2 |
|... | |... |
+--------------------+ +--------------+
-
Constructor Summary
ConstructorsConstructorDescriptionGroupedTopNRowNumberAccumulator(RowIdComparisonStrategy strategy, int topN, LongConsumer rowIdEvictionListener) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int groupId, RowReference rowReference) Add the specified row to this accumulator.longdrainTo(int groupId, LongBigArray rowIdOutput) Drain the contents of groupId from this accumulator to the provided output row ID buffer.intfindFirstPositionToAdd(Page newPage, int groupCount, int[] groupIds, PageWithPositionComparator comparator, RowReferencePageManager pageManager) longsizeOf()
-
Constructor Details
-
GroupedTopNRowNumberAccumulator
public GroupedTopNRowNumberAccumulator(RowIdComparisonStrategy strategy, int topN, LongConsumer rowIdEvictionListener)
-
-
Method Details
-
sizeOf
public long sizeOf() -
findFirstPositionToAdd
public int findFirstPositionToAdd(Page newPage, int groupCount, int[] groupIds, PageWithPositionComparator comparator, RowReferencePageManager pageManager) -
add
Add the specified row to this accumulator.This may trigger row eviction callbacks if other rows have to be evicted to make space.
- Returns:
- true if this row was incorporated, false otherwise
-
drainTo
Drain the contents of groupId from this accumulator to the provided output row ID buffer.Rows will be presented in increasing rank order. Draining will not trigger any row eviction callbacks. After this method completion, the Accumulator will contain zero rows for the specified groupId.
- Returns:
- number of rows deposited to the output buffer
-