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>
This
TopNAlgorithm is 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 the
PooledTopNAlgorithm for 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 the PooledTopNAlgorithm, 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
ConstructorsConstructorDescriptionAggregateTopNMetricFirstAlgorithm(TopNQuery query, TopNCursorInspector cursorInspector, NonBlockingPool<ByteBuffer> bufferPool) -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup(TopNParams params) makeInitParams(ColumnSelectorPlus selectorPlus, Cursor cursor, CursorGranularizer granularizer) voidrun(TopNParams params, TopNResultBuilder resultBuilder, int[] ints, TopNQueryMetrics queryMetrics)
-
Constructor Details
-
AggregateTopNMetricFirstAlgorithm
public AggregateTopNMetricFirstAlgorithm(TopNQuery query, TopNCursorInspector cursorInspector, NonBlockingPool<ByteBuffer> bufferPool)
-
-
Method Details
-
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
- Specified by:
cleanupin interfaceTopNAlgorithm<int[],TopNParams>
-