Package io.trino.util
Class HeapTraversal
java.lang.Object
io.trino.util.HeapTraversal
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]
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisTarget()voidresetWithPathTo(long targetNodeIndex) longsizeOf()
-
Constructor Details
-
HeapTraversal
public HeapTraversal()
-
-
Method Details
-
resetWithPathTo
public void resetWithPathTo(long targetNodeIndex) -
isTarget
public boolean isTarget() -
nextChild
-
sizeOf
public long sizeOf()
-