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;
}
Aggregations