use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class DoubleLastAggregationTest method testDoubleLastBufferAggregator.
@Test
public void testDoubleLastBufferAggregator() {
BufferAggregator agg = doubleLastAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleLastAggFactory.getMaxIntermediateSizeWithNulls()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0);
Assert.assertEquals(times[0], result.lhs.longValue());
Assert.assertEquals(doubles[0], result.rhs, 0.0001);
Assert.assertEquals((long) doubles[0], agg.getLong(buffer, 0));
Assert.assertEquals(doubles[0], agg.getDouble(buffer, 0), 0.0001);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class FloatLastAggregationTest method testFloatLastBufferAggregator.
@Test
public void testFloatLastBufferAggregator() {
BufferAggregator agg = floatLastAggregatorFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[floatLastAggregatorFactory.getMaxIntermediateSizeWithNulls()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Float> result = (Pair<Long, Float>) agg.get(buffer, 0);
Assert.assertEquals(times[0], result.lhs.longValue());
Assert.assertEquals(floats[0], result.rhs, 0.0001);
Assert.assertEquals((long) floats[0], agg.getLong(buffer, 0));
Assert.assertEquals(floats[0], agg.getFloat(buffer, 0), 0.0001);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class DoubleFirstAggregationTest method testDoubleFirstBufferAggregator.
@Test
public void testDoubleFirstBufferAggregator() {
BufferAggregator agg = doubleFirstAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleFirstAggFactory.getMaxIntermediateSizeWithNulls()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0);
Assert.assertEquals(times[1], result.lhs.longValue());
Assert.assertEquals(doubleValues[1], result.rhs, 0.0001);
Assert.assertEquals((long) doubleValues[1], agg.getLong(buffer, 0));
Assert.assertEquals(doubleValues[1], agg.getDouble(buffer, 0), 0.0001);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class DoubleFirstAggregationTest method testDoubleFirstCombiningBufferAggregator.
@Test
public void testDoubleFirstCombiningBufferAggregator() {
BufferAggregator agg = combiningAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleFirstAggFactory.getMaxIntermediateSizeWithNulls()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0);
Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2];
Assert.assertEquals(expected.lhs, result.lhs);
Assert.assertEquals(expected.rhs, result.rhs, 0.0001);
Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0));
Assert.assertEquals(expected.rhs, agg.getDouble(buffer, 0), 0.0001);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class LongFirstAggregationTest method testLongFirstBufferAggregator.
@Test
public void testLongFirstBufferAggregator() {
BufferAggregator agg = new LongFirstAggregatorFactory("billy", "nilly", "customTime").factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[longFirstAggFactory.getMaxIntermediateSizeWithNulls()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Long> result = (Pair<Long, Long>) agg.get(buffer, 0);
Assert.assertEquals(customTimes[1], result.lhs.longValue());
Assert.assertEquals(longValues[1], result.rhs.longValue());
Assert.assertEquals(longValues[1], agg.getLong(buffer, 0));
Assert.assertEquals(longValues[1], agg.getFloat(buffer, 0), 0.0001);
}
Aggregations