Package io.trino.operator
Class GroupedTopNRankAccumulator
java.lang.Object
io.trino.operator.GroupedTopNRankAccumulator
Memory Layout:
+----------------------+
|PeerGroupLookup |
+----------------------+
|Map: |
(Group1, RowID4)+->+(Group,RowID):HeapNode+-+
+----------------------+ |
|
+--------------------+ | +---------------+ +---------------+
|GroupIdToHeapBuffer | | |HeapNodeBuffer | |PeerGroupBuffer|
+--------------------+ | +---------------+ +---------------+
Group1+->+RootNodeIndex1+----------->+PeerGroupIndex1+--->+RowID1 |
|RootNodeIndex2 | | |PeerGroupCount1| |NextPeerIndex1+--+
|... | | |LeftChild1 +----+ |RowID2 | |
+--------------------+ | |RightChild1 | | |NextPeerIndex2 | |
|ValueCount1 | +->+PeerGroupIndex2+invalid input: '<'-+ |RowID3 invalid input: '<'-------+
|HeapSize1 | |PeerGroupCount2| |NextPeerIndex3 |
|ValueCount2 | |LeftChild2 | |... |
|HeapSize2 | |RightChild2 | +---------------+
|... | |... |
+--------------------+ +---------------+
-
Constructor Summary
ConstructorsConstructorDescriptionGroupedTopNRankAccumulator(RowIdComparisonHashStrategy 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 this accumulator to the provided output row ID.longdrainTo(int groupId, LongBigArray rowIdOutput, LongBigArray rankingOutput) Drain the contents of this accumulator to the provided output row ID and ranking buffer.intfindFirstPositionToAdd(Page newPage, int groupCount, int[] groupIds, PageWithPositionComparator comparator, RowReferencePageManager pageManager) longsizeOf()
-
Constructor Details
-
GroupedTopNRankAccumulator
public GroupedTopNRankAccumulator(RowIdComparisonHashStrategy 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 this accumulator to the provided output row ID and ranking 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 buffers
-
drainTo
Drain the contents of this accumulator to the provided output row ID.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
-