Package org.apache.druid.query.topn
Class HeapBasedTopNAlgorithm
java.lang.Object
org.apache.druid.query.topn.BaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor,TopNParams>
org.apache.druid.query.topn.HeapBasedTopNAlgorithm
- All Implemented Interfaces:
TopNAlgorithm<Aggregator[][],TopNParams>
public class HeapBasedTopNAlgorithm
extends BaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor,TopNParams>
Heap based topn algorithm that handles aggregates on dimension extractions and numeric typed dimension columns.
This has to be its own strategy because the pooled topn algorithm assumes each index is unique, and cannot handle
multiple index numerals referencing the same dimension value.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.druid.query.topn.BaseTopNAlgorithm
BaseTopNAlgorithm.AggregatorArrayProvider, BaseTopNAlgorithm.BaseArrayProvider<T> -
Field Summary
Fields inherited from class org.apache.druid.query.topn.BaseTopNAlgorithm
cursorInspectorFields inherited from interface org.apache.druid.query.topn.TopNAlgorithm
EMPTY_ARRAY, INIT_POSITION_VALUE, SKIP_POSITION_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionHeapBasedTopNAlgorithm(TopNQuery query, TopNCursorInspector cursorInspector) -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup(TopNParams params) protected TopNColumnAggregatesProcessormakeDimValAggregateStore(TopNParams params) protected Aggregator[][]makeDimValSelector(TopNParams params, int numProcessed, int numToProcess) makeInitParams(ColumnSelectorPlus<TopNColumnAggregatesProcessor> selectorPlus, Cursor cursor, CursorGranularizer granularizer) protected voidresetAggregators(TopNColumnAggregatesProcessor processor) protected longscanAndAggregate(TopNParams params, Aggregator[][] rowSelector, TopNColumnAggregatesProcessor processor) Returns the number of processed rows (i.protected Aggregator[][]updateDimValSelector(Aggregator[][] aggregators, int numProcessed, int numToProcess) protected voidupdateResults(TopNParams params, Aggregator[][] aggregators, TopNColumnAggregatesProcessor processor, TopNResultBuilder resultBuilder) Methods inherited from class org.apache.druid.query.topn.BaseTopNAlgorithm
computeNewLength, makeAggregators, makeBufferAggregators, makeResultBuilder, run
-
Constructor Details
-
HeapBasedTopNAlgorithm
-
-
Method Details
-
makeInitParams
public TopNParams makeInitParams(ColumnSelectorPlus<TopNColumnAggregatesProcessor> selectorPlus, Cursor cursor, CursorGranularizer granularizer) -
makeDimValSelector
- Specified by:
makeDimValSelectorin classBaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor, TopNParams>
-
updateDimValSelector
protected Aggregator[][] updateDimValSelector(Aggregator[][] aggregators, int numProcessed, int numToProcess) - Specified by:
updateDimValSelectorin classBaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor, TopNParams>
-
makeDimValAggregateStore
- Specified by:
makeDimValAggregateStorein classBaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor, TopNParams>
-
scanAndAggregate
protected long scanAndAggregate(TopNParams params, Aggregator[][] rowSelector, TopNColumnAggregatesProcessor processor) Description copied from class:BaseTopNAlgorithmReturns the number of processed rows (i. e. after postFilters are applied inside the cursor being processed).- Specified by:
scanAndAggregatein classBaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor, TopNParams>
-
updateResults
protected void updateResults(TopNParams params, Aggregator[][] aggregators, TopNColumnAggregatesProcessor processor, TopNResultBuilder resultBuilder) - Specified by:
updateResultsin classBaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor, TopNParams>
-
resetAggregators
- Specified by:
resetAggregatorsin classBaseTopNAlgorithm<Aggregator[][],TopNColumnAggregatesProcessor, TopNParams>
-
cleanup
-