use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class StringLastAggregationTest method testStringLastBufferAggregator.
@Test
public void testStringLastBufferAggregator() {
BufferAggregator agg = stringLastAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[stringLastAggFactory.getMaxIntermediateSize()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, String> result = (Pair<Long, String>) agg.get(buffer, 0);
Assert.assertEquals(strings[0], result.rhs);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class StringLastAggregationTest method testStringLastCombiningBufferAggregator.
@Test
public void testStringLastCombiningBufferAggregator() {
BufferAggregator agg = combiningAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[stringLastAggFactory.getMaxIntermediateSize()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, String> result = (Pair<Long, String>) agg.get(buffer, 0);
Pair<Long, String> expected = pairs[2];
Assert.assertEquals(expected.lhs, result.lhs);
Assert.assertEquals(expected.rhs, result.rhs);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class StringLastAggregationTest method testStringLastBufferAggregatorWithTimeColumn.
@Test
public void testStringLastBufferAggregatorWithTimeColumn() {
BufferAggregator agg = new StringLastAggregatorFactory("billy", "nilly", "customTime", MAX_STRING_SIZE).factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[stringLastAggFactory.getMaxIntermediateSize()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, String> result = (Pair<Long, String>) agg.get(buffer, 0);
Assert.assertEquals(strings[1], result.rhs);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class FloatFirstAggregationTest method testFloatFirstBufferAggregator.
@Test
public void testFloatFirstBufferAggregator() {
BufferAggregator agg = floatFirstAggregatorFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[floatFirstAggregatorFactory.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[1], result.lhs.longValue());
Assert.assertEquals(floats[1], result.rhs, 0.0001);
Assert.assertEquals((long) floats[1], agg.getLong(buffer, 0));
Assert.assertEquals(floats[1], agg.getFloat(buffer, 0), 0.0001);
}
use of org.apache.druid.query.aggregation.BufferAggregator in project druid by druid-io.
the class FloatFirstAggregationTest method testFloatFirstCombiningBufferAggregator.
@Test
public void testFloatFirstCombiningBufferAggregator() {
BufferAggregator agg = combiningAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[floatFirstAggregatorFactory.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);
Pair<Long, Float> expected = (Pair<Long, Float>) 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.getFloat(buffer, 0), 0.0001);
}
Aggregations