Class GroupedTopNRowNumberAccumulator

java.lang.Object
io.trino.operator.GroupedTopNRowNumberAccumulator

public class GroupedTopNRowNumberAccumulator extends Object
Memory Layout:
          +--------------------+   +--------------+
          |GroupIdToHeapBuffer |   |HeapNodeBuffer|
          +--------------------+   +--------------+
 Group1+->+RootNodeIndex1+-------->+RowID1        |
          |RootNodeIndex2      |   |LeftChild1+-----+
          |...                 |   |RightChild1   | |
          +--------------------+   |RowID2    <-----+
          |HeapSize1           |   |LeftChild2    |
          |HeapSize2           |   |RightChild2   |
          |...                 |   |...           |
          +--------------------+   +--------------+
 
  • Constructor Details

  • Method Details

    • sizeOf

      public long sizeOf()
    • add

      public boolean add(long groupId, RowReference rowReference)
      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

      public long drainTo(long groupId, LongBigArray rowIdOutput)
      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