Package org.apache.druid.query.topn
Class AggregateTopNMetricFirstAlgorithm
- java.lang.Object
-
- org.apache.druid.query.topn.AggregateTopNMetricFirstAlgorithm
-
- All Implemented Interfaces:
TopNAlgorithm<int[],TopNParams>
public class AggregateTopNMetricFirstAlgorithm extends Object implements TopNAlgorithm<int[],TopNParams>
ThisTopNAlgorithmis tailored to processing aggregates on high cardility columns which are likely to have larger result sets. Internally it uses a 2 phase approach to compute the top-n result using thePooledTopNAlgorithmfor each phase. The first phase is to process the segment with only the order-by aggregator to compute which values constitute the top 'n' results. With this information, a actual result set is computed by a second run of thePooledTopNAlgorithm, this time with all aggregators, but only considering the values from the 'n' results to avoid performing any aggregations that would have been thrown away for results that didn't make the top-n.
-
-
Field Summary
-
Fields inherited from interface org.apache.druid.query.topn.TopNAlgorithm
EMPTY_ARRAY, INIT_POSITION_VALUE, SKIP_POSITION_VALUE
-
-
Constructor Summary
Constructors Constructor Description AggregateTopNMetricFirstAlgorithm(TopNQuery query, TopNCursorInspector cursorInspector, NonBlockingPool<ByteBuffer> bufferPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanup(TopNParams params)TopNParamsmakeInitParams(ColumnSelectorPlus selectorPlus, Cursor cursor, CursorGranularizer granularizer)voidrun(TopNParams params, TopNResultBuilder resultBuilder, int[] ints, TopNQueryMetrics queryMetrics)
-
-
-
Constructor Detail
-
AggregateTopNMetricFirstAlgorithm
public AggregateTopNMetricFirstAlgorithm(TopNQuery query, TopNCursorInspector cursorInspector, NonBlockingPool<ByteBuffer> bufferPool)
-
-
Method Detail
-
makeInitParams
public TopNParams makeInitParams(ColumnSelectorPlus selectorPlus, Cursor cursor, CursorGranularizer granularizer)
- Specified by:
makeInitParamsin interfaceTopNAlgorithm<int[],TopNParams>
-
run
public void run(TopNParams params, TopNResultBuilder resultBuilder, int[] ints, @Nullable TopNQueryMetrics queryMetrics)
- Specified by:
runin interfaceTopNAlgorithm<int[],TopNParams>
-
cleanup
public void cleanup(TopNParams params)
- Specified by:
cleanupin interfaceTopNAlgorithm<int[],TopNParams>
-
-