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>
ThisTopNAlgorithm
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 thePooledTopNAlgorithm
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 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(StorageAdapter storageAdapter, TopNQuery query, NonBlockingPool<ByteBuffer> bufferPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup(TopNParams params)
TopNParams
makeInitParams(ColumnSelectorPlus selectorPlus, Cursor cursor)
void
run(TopNParams params, TopNResultBuilder resultBuilder, int[] ints, TopNQueryMetrics queryMetrics)
-
-
-
Constructor Detail
-
AggregateTopNMetricFirstAlgorithm
public AggregateTopNMetricFirstAlgorithm(StorageAdapter storageAdapter, TopNQuery query, NonBlockingPool<ByteBuffer> bufferPool)
-
-
Method Detail
-
makeInitParams
public TopNParams makeInitParams(ColumnSelectorPlus selectorPlus, Cursor cursor)
- Specified by:
makeInitParams
in interfaceTopNAlgorithm<int[],TopNParams>
-
run
public void run(TopNParams params, TopNResultBuilder resultBuilder, int[] ints, @Nullable TopNQueryMetrics queryMetrics)
- Specified by:
run
in interfaceTopNAlgorithm<int[],TopNParams>
-
cleanup
public void cleanup(TopNParams params)
- Specified by:
cleanup
in interfaceTopNAlgorithm<int[],TopNParams>
-
-