Package org.apache.druid.frame.processor
Class TournamentTree
- java.lang.Object
-
- org.apache.druid.frame.processor.TournamentTree
-
public class TournamentTree extends Object
Tree-of-losers tournament tree used for K-way merging. The tree contains a fixed set of elements, from 0 (inclusive) tonumElements(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 intree[0]. When used as part of k-way merge, expected usage is callgetMin()to retrieve a run number, then read an element from the run. On the next call togetMin(), the tree internally callsupdate()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
Constructors Constructor Description TournamentTree(int numElements, it.unimi.dsi.fastutil.ints.IntComparator comparator)Creates a tree with a certain number of elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetMin()Get the current minimum element (the overall winner, i.e., the run to pull the next element from in the K-way merge).StringtoString()
-