Search in sources :

Example 6 with ColumnSelectorPlus

use of io.druid.query.ColumnSelectorPlus in project druid by druid-io.

the class CardinalityAggregatorTest method testBufferAggregateValues.

@Test
public void testBufferAggregateValues() throws Exception {
    CardinalityBufferAggregator agg = new CardinalityBufferAggregator(dimInfoList.toArray(new ColumnSelectorPlus[] {}), false);
    int maxSize = valueAggregatorFactory.getMaxIntermediateSize();
    ByteBuffer buf = ByteBuffer.allocate(maxSize + 64);
    int pos = 10;
    buf.limit(pos + maxSize);
    agg.init(buf, pos);
    for (int i = 0; i < values1.size(); ++i) {
        bufferAggregate(selectorList, agg, buf, pos);
    }
    Assert.assertEquals(7.0, (Double) valueAggregatorFactory.finalizeComputation(agg.get(buf, pos)), 0.05);
}
Also used : ColumnSelectorPlus(io.druid.query.ColumnSelectorPlus) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

ColumnSelectorPlus (io.druid.query.ColumnSelectorPlus)6 ByteBuffer (java.nio.ByteBuffer)3 DimensionSpec (io.druid.query.dimension.DimensionSpec)2 Test (org.junit.Test)2 IAE (io.druid.java.util.common.IAE)1 ISE (io.druid.java.util.common.ISE)1 BaseSequence (io.druid.java.util.common.guava.BaseSequence)1 Sequence (io.druid.java.util.common.guava.Sequence)1 CardinalityAggregatorColumnSelectorStrategy (io.druid.query.aggregation.cardinality.types.CardinalityAggregatorColumnSelectorStrategy)1 StringCardinalityAggregatorColumnSelectorStrategy (io.druid.query.aggregation.cardinality.types.StringCardinalityAggregatorColumnSelectorStrategy)1 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)1 GroupByColumnSelectorPlus (io.druid.query.groupby.epinephelinae.column.GroupByColumnSelectorPlus)1 Cursor (io.druid.segment.Cursor)1 DimensionSelector (io.druid.segment.DimensionSelector)1 Closeable (java.io.Closeable)1 DateTime (org.joda.time.DateTime)1 Interval (org.joda.time.Interval)1