Search in sources :

Example 41 with IndexedInts

use of io.druid.segment.data.IndexedInts in project druid by druid-io.

the class Generic2AggPooledTopNScannerPrototype method scanAndAggregate.

@Override
public long scanAndAggregate(DimensionSelector dimensionSelector, BufferAggregator aggregator1, int aggregator1Size, BufferAggregator aggregator2, int aggregator2Size, Cursor cursor, int[] positions, ByteBuffer resultsBuffer) {
    int totalAggregatorsSize = aggregator1Size + aggregator2Size;
    long scannedRows = 0;
    int positionToAllocate = 0;
    while (!cursor.isDoneOrInterrupted()) {
        final IndexedInts dimValues = dimensionSelector.getRow();
        final int dimSize = dimValues.size();
        for (int i = 0; i < dimSize; i++) {
            int dimIndex = dimValues.get(i);
            int position = positions[dimIndex];
            if (position >= 0) {
                aggregator1.aggregate(resultsBuffer, position);
                aggregator2.aggregate(resultsBuffer, position + aggregator1Size);
            } else if (position == TopNAlgorithm.INIT_POSITION_VALUE) {
                positions[dimIndex] = positionToAllocate;
                position = positionToAllocate;
                aggregator1.init(resultsBuffer, position);
                aggregator1.aggregate(resultsBuffer, position);
                position += aggregator1Size;
                aggregator2.init(resultsBuffer, position);
                aggregator2.aggregate(resultsBuffer, position);
                positionToAllocate += totalAggregatorsSize;
            }
        }
        scannedRows++;
        cursor.advanceUninterruptibly();
    }
    return scannedRows;
}
Also used : IndexedInts(io.druid.segment.data.IndexedInts)

Aggregations

IndexedInts (io.druid.segment.data.IndexedInts)41 DimensionSelector (io.druid.segment.DimensionSelector)14 ValueMatcher (io.druid.query.filter.ValueMatcher)9 ArrayBasedIndexedInts (io.druid.segment.data.ArrayBasedIndexedInts)8 Test (org.junit.Test)8 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)6 Cursor (io.druid.segment.Cursor)6 BooleanValueMatcher (io.druid.segment.filter.BooleanValueMatcher)6 ArrayList (java.util.ArrayList)5 ByteBuffer (java.nio.ByteBuffer)3 BitSet (java.util.BitSet)3 Function (com.google.common.base.Function)2 ImmutableList (com.google.common.collect.ImmutableList)2 IAE (io.druid.java.util.common.IAE)2 Aggregator (io.druid.query.aggregation.Aggregator)2 DimFilter (io.druid.query.filter.DimFilter)2 ColumnSelectorFactory (io.druid.segment.ColumnSelectorFactory)2 IdLookup (io.druid.segment.IdLookup)2 CompressedVSizeIntsIndexedSupplier (io.druid.segment.data.CompressedVSizeIntsIndexedSupplier)2 IncrementalIndexTest (io.druid.segment.data.IncrementalIndexTest)2