Search in sources :

Example 1 with SimpleDoubleBufferAggregator

use of org.apache.druid.query.aggregation.SimpleDoubleBufferAggregator 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;
        });
    }
}
Also used : FilteredOffset(org.apache.druid.segment.FilteredOffset) HistoricalDimensionSelector(org.apache.druid.segment.historical.HistoricalDimensionSelector) SingleValueHistoricalDimensionSelector(org.apache.druid.segment.historical.SingleValueHistoricalDimensionSelector) HistoricalCursor(org.apache.druid.segment.historical.HistoricalCursor) SimpleDoubleBufferAggregator(org.apache.druid.query.aggregation.SimpleDoubleBufferAggregator) SingleValueHistoricalDimensionSelector(org.apache.druid.segment.historical.SingleValueHistoricalDimensionSelector) HistoricalCursor(org.apache.druid.segment.historical.HistoricalCursor) Cursor(org.apache.druid.segment.Cursor) BufferAggregator(org.apache.druid.query.aggregation.BufferAggregator) SimpleDoubleBufferAggregator(org.apache.druid.query.aggregation.SimpleDoubleBufferAggregator) HistoricalColumnSelector(org.apache.druid.segment.historical.HistoricalColumnSelector)

Aggregations

BufferAggregator (org.apache.druid.query.aggregation.BufferAggregator)1 SimpleDoubleBufferAggregator (org.apache.druid.query.aggregation.SimpleDoubleBufferAggregator)1 Cursor (org.apache.druid.segment.Cursor)1 FilteredOffset (org.apache.druid.segment.FilteredOffset)1 HistoricalColumnSelector (org.apache.druid.segment.historical.HistoricalColumnSelector)1 HistoricalCursor (org.apache.druid.segment.historical.HistoricalCursor)1 HistoricalDimensionSelector (org.apache.druid.segment.historical.HistoricalDimensionSelector)1 SingleValueHistoricalDimensionSelector (org.apache.druid.segment.historical.SingleValueHistoricalDimensionSelector)1