Class NullableNumericTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>
- java.lang.Object
-
- org.apache.druid.query.topn.types.NullableNumericTopNColumnAggregatesProcessor<Selector>
-
- All Implemented Interfaces:
ColumnSelectorStrategy,TopNColumnAggregatesProcessor<Selector>
- Direct Known Subclasses:
DoubleTopNColumnAggregatesProcessor,FloatTopNColumnAggregatesProcessor,LongTopNColumnAggregatesProcessor
public abstract class NullableNumericTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector> extends Object implements TopNColumnAggregatesProcessor<Selector>
BaseTopNColumnAggregatesProcessorforBaseNullableColumnValueSelector. Non-null selector values aggregates are stored in a type appropriate primitive map, created byTopNColumnAggregatesProcessor.initAggregateStore()and available viagetAggregatesStore(), and null valued row aggregates are stored in a separatenullValueAggregatesAggregatorarray.updateResults(org.apache.druid.query.topn.TopNResultBuilder)will combine both the map and null aggregates to populate theTopNResultBuilderwith the values produced byscanAndAggregate(org.apache.druid.query.topn.TopNQuery, Selector, org.apache.druid.segment.Cursor, org.apache.druid.query.aggregation.Aggregator[][]).
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedNullableNumericTopNColumnAggregatesProcessor(Function<Object,Object> converter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseAggregators()Closes all on heapAggregatorassociated with the aggregates processorintgetCardinality(Selector selector)Get value cardinality of underlyingColumnValueSelectorAggregator[][]getRowSelector(TopNQuery query, TopNParams params, StorageAdapter storageAdapter)Used byHeapBasedTopNAlgorithm.longscanAndAggregate(TopNQuery query, Selector selector, Cursor cursor, Aggregator[][] rowSelector)Used byHeapBasedTopNAlgorithm.voidupdateResults(TopNResultBuilder resultBuilder)Used byHeapBasedTopNAlgorithm.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.query.topn.types.TopNColumnAggregatesProcessor
initAggregateStore
-
-
-
-
Method Detail
-
getCardinality
public int getCardinality(Selector selector)
Description copied from interface:TopNColumnAggregatesProcessorGet value cardinality of underlyingColumnValueSelector- Specified by:
getCardinalityin interfaceTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>
-
getRowSelector
public Aggregator[][] getRowSelector(TopNQuery query, TopNParams params, StorageAdapter storageAdapter)
Description copied from interface:TopNColumnAggregatesProcessorUsed byHeapBasedTopNAlgorithm. Create an Aggregator[][] usingBaseTopNAlgorithm.AggregatorArrayProviderand 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.- Specified by:
getRowSelectorin interfaceTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>- Parameters:
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 not- Returns:
- an Aggregator[][] for integer-valued dimensions, null otherwise
-
scanAndAggregate
public long scanAndAggregate(TopNQuery query, Selector selector, Cursor cursor, Aggregator[][] rowSelector)
Description copied from interface:TopNColumnAggregatesProcessorUsed byHeapBasedTopNAlgorithm. The contract of this method requires callingTopNColumnAggregatesProcessor.initAggregateStore()prior to calling this method. Iterate through theCursor, 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[] usingBaseTopNAlgorithm.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. CallAggregator.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.- Specified by:
scanAndAggregatein interfaceTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>- Parameters:
query- The TopN query being served.selector- Dimension value selectorcursor- Cursor for the segment being queriedrowSelector- Integer lookup containing aggregators- Returns:
- the number of processed rows (after postFilters are applied inside the cursor being processed)
-
updateResults
public void updateResults(TopNResultBuilder resultBuilder)
Description copied from interface:TopNColumnAggregatesProcessorUsed byHeapBasedTopNAlgorithm. Read entries from the aggregates store, adding the keys and associated values to the resultBuilder, applying the valueTransformer to the keys if present- Specified by:
updateResultsin interfaceTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>- Parameters:
resultBuilder- TopN result builder
-
closeAggregators
public void closeAggregators()
Description copied from interface:TopNColumnAggregatesProcessorCloses all on heapAggregatorassociated with the aggregates processor- Specified by:
closeAggregatorsin interfaceTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>
-
-