public abstract class NullableNumericTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector> extends Object implements TopNColumnAggregatesProcessor<Selector>
TopNColumnAggregatesProcessor for BaseNullableColumnValueSelector. Non-null selector values
aggregates are stored in a type appropriate primitive map, created by TopNColumnAggregatesProcessor.initAggregateStore() and available
via getAggregatesStore(), and null valued row aggregates are stored in a separate
nullValueAggregates Aggregator array.
updateResults(org.apache.druid.query.topn.TopNResultBuilder) will combine both the map and null aggregates to populate the TopNResultBuilder with
the values produced by scanAndAggregate(org.apache.druid.query.topn.TopNQuery, Selector, org.apache.druid.segment.Cursor, org.apache.druid.query.aggregation.Aggregator[][]).| Modifier | Constructor and Description |
|---|---|
protected |
NullableNumericTopNColumnAggregatesProcessor(Function<Object,Comparable<?>> converter) |
| Modifier and Type | Method and Description |
|---|---|
void |
closeAggregators()
Closes all on heap
Aggregator associated withe the aggregates processor |
int |
getCardinality(Selector selector)
Get value cardinality of underlying
ColumnValueSelector |
Aggregator[][] |
getRowSelector(TopNQuery query,
TopNParams params,
StorageAdapter storageAdapter)
Used by
HeapBasedTopNAlgorithm. |
long |
scanAndAggregate(TopNQuery query,
Selector selector,
Cursor cursor,
Aggregator[][] rowSelector)
Used by
HeapBasedTopNAlgorithm. |
void |
updateResults(TopNResultBuilder resultBuilder)
Used by
HeapBasedTopNAlgorithm. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitAggregateStoreprotected NullableNumericTopNColumnAggregatesProcessor(Function<Object,Comparable<?>> converter)
public int getCardinality(Selector selector)
TopNColumnAggregatesProcessorColumnValueSelectorgetCardinality in interface TopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>public Aggregator[][] getRowSelector(TopNQuery query, TopNParams params, StorageAdapter storageAdapter)
TopNColumnAggregatesProcessorHeapBasedTopNAlgorithm.
Create an Aggregator[][] using BaseTopNAlgorithm.AggregatorArrayProvider and
the given parameters.
As the Aggregator[][] is used as an integer-based lookup, this method is only applicable for dimension types
that use integer row values, e.g. string columns where the value cardinality is known.
A dimension type that does not have integer values should return null.getRowSelector in interface TopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>query - The TopN query being servedparams - Parameters for the TopN query being servedstorageAdapter - Column storage adapter, to provide information about the column that can be used for
query optimization, e.g. whether dimension values are sorted or notpublic long scanAndAggregate(TopNQuery query, Selector selector, Cursor cursor, Aggregator[][] rowSelector)
TopNColumnAggregatesProcessorHeapBasedTopNAlgorithm. The contract of this method requires calling TopNColumnAggregatesProcessor.initAggregateStore()
prior to calling this method.
Iterate through the Cursor, reading the current row from a dimension value selector, and for each row
value:
1. Retrieve the Aggregator[] for the row value from rowSelector (fast integer lookup), usable if value cardinality
is known, or from aggregatesStore (slower map).
2. If the rowSelector/aggregatesStore did not have an entry for a particular row value, this function
should retrieve the current Aggregator[] using
BaseTopNAlgorithm.makeAggregators(org.apache.druid.segment.Cursor, java.util.List<org.apache.druid.query.aggregation.AggregatorFactory>) and the provided cursor and query,
storing them in rowSelector/aggregatesStore
3. Call Aggregator.aggregate() on each of the aggregators.
If a dimension type doesn't have integer values, it should ignore rowSelector and use the aggregatesStore map only.scanAndAggregate in interface TopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>query - The TopN query being served.selector - Dimension value selectorcursor - Cursor for the segment being queriedrowSelector - Integer lookup containing aggregatorspublic void updateResults(TopNResultBuilder resultBuilder)
TopNColumnAggregatesProcessorHeapBasedTopNAlgorithm.
Read entries from the aggregates store, adding the keys and associated values to the resultBuilder, applying the
valueTransformer to the keys if presentupdateResults in interface TopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>resultBuilder - TopN result builderpublic void closeAggregators()
TopNColumnAggregatesProcessorAggregator associated withe the aggregates processorcloseAggregators in interface TopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.