Package org.apache.druid.frame.processor
Class TournamentTree
java.lang.Object
org.apache.druid.frame.processor.TournamentTree
Tree-of-losers tournament tree used for K-way merging. The tree contains a fixed set of elements, from 0 (inclusive)
to
numElements (exclusive).
The tree represents a tournament played amongst the elements. At all times each node of the tree contains the loser
of the match at that node. The winners of the matches are not explicitly stored, except for the overall winner of
the tournament, which is stored in tree[0].
When used as part of k-way merge, expected usage is call getMin() to retrieve a run number, then read
an element from the run. On the next call to getMin(), the tree internally calls update() to
handle the case where the min needs to change.
Refer to https://en.wikipedia.org/wiki/K-way_merge_algorithm#Tournament_Tree for additional details.-
Constructor Summary
ConstructorsConstructorDescriptionTournamentTree(int numElements, it.unimi.dsi.fastutil.ints.IntComparator comparator) Creates a tree with a certain number of elements. -
Method Summary
-
Constructor Details
-
TournamentTree
public TournamentTree(int numElements, it.unimi.dsi.fastutil.ints.IntComparator comparator) Creates a tree with a certain number of elements.- Parameters:
numElements- number of elements in the treecomparator- comparator for the elements. Smaller elements "win".
-
-
Method Details