use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class StringLastAggregationTest method testStringLastCombiningAggregator.
@Test
public void testStringLastCombiningAggregator() {
Aggregator agg = combiningAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, String> result = (Pair<Long, String>) agg.get();
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.Aggregator in project druid by druid-io.
the class DoubleFirstAggregationTest method testDoubleFirstCombiningAggregator.
@Test
public void testDoubleFirstCombiningAggregator() {
Aggregator agg = combiningAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Double> result = (Pair<Long, Double>) agg.get();
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());
Assert.assertEquals(expected.rhs, agg.getDouble(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class DoubleFirstAggregationTest method testDoubleFirstAggregatorWithTimeColumn.
@Test
public void testDoubleFirstAggregatorWithTimeColumn() {
Aggregator agg = new DoubleFirstAggregatorFactory("billy", "nilly", "customTime").factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Double> result = (Pair<Long, Double>) agg.get();
Assert.assertEquals(customTimes[1], result.lhs.longValue());
Assert.assertEquals(doubleValues[1], result.rhs, 0.0001);
Assert.assertEquals((long) doubleValues[1], agg.getLong());
Assert.assertEquals(doubleValues[1], agg.getDouble(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class LongFirstAggregationTest method testLongFirstAggregatorWithTimeColumn.
@Test
public void testLongFirstAggregatorWithTimeColumn() {
Aggregator agg = new LongFirstAggregatorFactory("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(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class LongFirstAggregationTest method testLongFirstAggregator.
@Test
public void testLongFirstAggregator() {
Aggregator agg = longFirstAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Long> result = (Pair<Long, Long>) agg.get();
Assert.assertEquals(times[3], result.lhs.longValue());
Assert.assertEquals(longValues[3], result.rhs.longValue());
Assert.assertEquals(longValues[3], agg.getLong());
Assert.assertEquals(longValues[3], agg.getFloat(), 0.0001);
}
Aggregations