Package io.trino.util

Class HeapTraversal

java.lang.Object
io.trino.util.HeapTraversal

public class HeapTraversal extends Object
If heap nodes are numbered top down, and left to right as follows:
             Node1
          /        \
       Node2       Node3
      /    \       /
   Node4 Node5  Node6 ...
 
We can compute the path from the root to each node by following the binary sequence of 0's and 1s of the index as follows: 1. Starting from the most significant 1 bit, shift to the next most significant bit. If this bit is 0, we need to move to the root's left child, otherwise move to the right child. 2. From the context of this new node, observe the next most significant bit. If this bit is 0, we need to move to this node's left child, otherwise move to the right child. 3. Repeat until all significant bits have been consumed.
 Examples:
 - Node4 => 100 => 1 [ROOT] - 0 [GO LEFT] - 0 [GO LEFT]
 - Node6 => 110 => 1 [ROOT] - 1 [GO RIGHT] - 0 [GO LEFT]
 
  • Constructor Details

    • HeapTraversal

      public HeapTraversal()
  • Method Details

    • resetWithPathTo

      public void resetWithPathTo(long targetNodeIndex)
    • isTarget

      public boolean isTarget()
    • nextChild

      public HeapTraversal.Child nextChild()
    • sizeOf

      public long sizeOf()