use of org.apache.druid.segment.historical.HistoricalCursor in project druid by druid-io.
the class PooledTopNAlgorithm method computeSpecializedScanAndAggregateImplementations.
private static void computeSpecializedScanAndAggregateImplementations() {
SPECIALIZED_SCAN_AND_AGGREGATE_IMPLEMENTATIONS.clear();
// The order of the following `if` blocks matters, "more specialized" implementations go first
if (SPECIALIZE_HISTORICAL_SINGLE_VALUE_DIM_SELECTOR_ONE_SIMPLE_DOUBLE_AGG_POOLED_TOPN) {
SPECIALIZED_SCAN_AND_AGGREGATE_IMPLEMENTATIONS.add((params, positions, theAggregators) -> {
if (theAggregators.length == 1) {
BufferAggregator aggregator = theAggregators[0];
final Cursor cursor = params.getCursor();
if (cursor instanceof HistoricalCursor && // doesn't clone offset anymore.
!(((HistoricalCursor) cursor).getOffset() instanceof FilteredOffset) && aggregator instanceof SimpleDoubleBufferAggregator && params.getDimSelector() instanceof SingleValueHistoricalDimensionSelector && ((SimpleDoubleBufferAggregator) aggregator).getSelector() instanceof HistoricalColumnSelector) {
return scanAndAggregateHistorical1SimpleDoubleAgg(params, positions, (SimpleDoubleBufferAggregator) aggregator, (HistoricalCursor) cursor, DEFAULT_HISTORICAL_SINGLE_VALUE_DIM_SELECTOR_ONE_SIMPLE_DOUBLE_AGG_SCANNER);
}
}
return -1;
});
}
if (SPECIALIZE_HISTORICAL_ONE_SIMPLE_DOUBLE_AGG_POOLED_TOPN) {
SPECIALIZED_SCAN_AND_AGGREGATE_IMPLEMENTATIONS.add((params, positions, theAggregators) -> {
if (theAggregators.length == 1) {
BufferAggregator aggregator = theAggregators[0];
final Cursor cursor = params.getCursor();
if (cursor instanceof HistoricalCursor && // doesn't clone offset anymore.
!(((HistoricalCursor) cursor).getOffset() instanceof FilteredOffset) && aggregator instanceof SimpleDoubleBufferAggregator && params.getDimSelector() instanceof HistoricalDimensionSelector && ((SimpleDoubleBufferAggregator) aggregator).getSelector() instanceof HistoricalColumnSelector) {
return scanAndAggregateHistorical1SimpleDoubleAgg(params, positions, (SimpleDoubleBufferAggregator) aggregator, (HistoricalCursor) cursor, DEFAULT_HISTORICAL_ONE_SIMPLE_DOUBLE_AGG_SCANNER);
}
}
return -1;
});
}
if (SPECIALIZE_GENERIC_ONE_AGG_POOLED_TOPN) {
SPECIALIZED_SCAN_AND_AGGREGATE_IMPLEMENTATIONS.add((params, positions, theAggregators) -> {
if (theAggregators.length == 1) {
return scanAndAggregateGeneric1Agg(params, positions, theAggregators[0], params.getCursor());
}
return -1;
});
}
if (SPECIALIZE_GENERIC_TWO_AGG_POOLED_TOPN) {
SPECIALIZED_SCAN_AND_AGGREGATE_IMPLEMENTATIONS.add((params, positions, theAggregators) -> {
if (theAggregators.length == 2) {
return scanAndAggregateGeneric2Agg(params, positions, theAggregators, params.getCursor());
}
return -1;
});
}
}
Aggregations