use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class DoubleLastAggregationTest method testDoubleLastAggregator.
@Test
public void testDoubleLastAggregator() {
Aggregator agg = doubleLastAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Double> result = (Pair<Long, Double>) agg.get();
Assert.assertEquals(times[0], result.lhs.longValue());
Assert.assertEquals(doubles[0], result.rhs, 0.0001);
Assert.assertEquals((long) doubles[0], agg.getLong());
Assert.assertEquals(doubles[0], agg.getDouble(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class LongLastAggregationTest method testLongLastAggregator.
@Test
public void testLongLastAggregator() {
Aggregator agg = longLastAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Long> result = (Pair<Long, Long>) agg.get();
Assert.assertEquals(times[2], result.lhs.longValue());
Assert.assertEquals(longValues[2], result.rhs.longValue());
Assert.assertEquals(longValues[2], agg.getLong());
Assert.assertEquals(longValues[2], agg.getFloat(), 1);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class LongLastAggregationTest method testLongLastAggregatorWithTimeColumn.
@Test
public void testLongLastAggregatorWithTimeColumn() {
Aggregator agg = new LongLastAggregatorFactory("billy", "nilly", "customTime").factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Long> result = (Pair<Long, Long>) agg.get();
Assert.assertEquals(customTimes[1], result.lhs.longValue());
Assert.assertEquals(longValues[1], result.rhs.longValue());
Assert.assertEquals(longValues[1], agg.getLong());
Assert.assertEquals(longValues[1], agg.getFloat(), 1);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class FloatFirstAggregationTest method testFloatFirstAggregator.
@Test
public void testFloatFirstAggregator() {
Aggregator agg = floatFirstAggregatorFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Float> result = (Pair<Long, Float>) agg.get();
Assert.assertEquals(times[1], result.lhs.longValue());
Assert.assertEquals(floats[1], result.rhs, 0.0001);
Assert.assertEquals((long) floats[1], agg.getLong());
Assert.assertEquals(floats[1], agg.getFloat(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class StringFirstAggregationTest method testStringFirstAggregator.
@Test
public void testStringFirstAggregator() {
Aggregator agg = stringFirstAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, String> result = (Pair<Long, String>) agg.get();
Assert.assertEquals(strings[2], result.rhs);
}
Aggregations