use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class FloatLastAggregationTest method testFloatLastCombiningAggregator.
@Test
public void testFloatLastCombiningAggregator() {
Aggregator agg = combiningAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, Float> result = (Pair<Long, Float>) agg.get();
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());
Assert.assertEquals(expected.rhs, agg.getFloat(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class StringLastAggregationTest method testStringLastAggregator.
@Test
public void testStringLastAggregator() {
Aggregator agg = stringLastAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, String> result = (Pair<Long, String>) agg.get();
Assert.assertEquals(strings[0], result.rhs);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class StringLastAggregationTest method testStringLastAggregatorWithTimeColumn.
@Test
public void testStringLastAggregatorWithTimeColumn() {
Aggregator agg = new StringLastAggregatorFactory("billy", "nilly", "customTime", MAX_STRING_SIZE).factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Pair<Long, String> result = (Pair<Long, String>) agg.get();
Assert.assertEquals(strings[1], result.rhs);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class DoubleLastAggregationTest method testDoubleLastAggregatorWithTimeColumn.
@Test
public void testDoubleLastAggregatorWithTimeColumn() {
Aggregator agg = new DoubleLastAggregatorFactory("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(doubles[1], result.rhs, 0.0001);
Assert.assertEquals((long) doubles[1], agg.getLong());
Assert.assertEquals(doubles[1], agg.getDouble(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class DoubleLastAggregationTest method testDoubleLastCombiningAggregator.
@Test
public void testDoubleLastCombiningAggregator() {
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);
}
Aggregations