use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class DoubleAnyAggregationTest method testDoubleAnyCombiningAggregator.
@Test
public void testDoubleAnyCombiningAggregator() {
Aggregator agg = combiningAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Double result = (Double) agg.get();
Assert.assertEquals(objects[0], result, 0.0001);
Assert.assertEquals(objects[0].longValue(), agg.getLong());
Assert.assertEquals(objects[0], agg.getDouble(), 0.0001);
}
use of org.apache.druid.query.aggregation.Aggregator in project druid by druid-io.
the class DoubleAnyAggregationTest method testDoubleAnyAggregator.
@Test
public void testDoubleAnyAggregator() {
Aggregator agg = doubleAnyAggFactory.factorize(colSelectorFactory);
aggregate(agg);
aggregate(agg);
aggregate(agg);
aggregate(agg);
Double result = (Double) agg.get();
Assert.assertEquals((Double) doubles[0], result);
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 BaseFilterTest method selectCountUsingFilteredAggregator.
private long selectCountUsingFilteredAggregator(final DimFilter filter) {
final Sequence<Cursor> cursors = makeCursorSequence(null);
Sequence<Aggregator> aggSeq = Sequences.map(cursors, cursor -> {
Aggregator agg = new FilteredAggregatorFactory(new CountAggregatorFactory("count"), maybeOptimize(filter)).factorize(cursor.getColumnSelectorFactory());
for (; !cursor.isDone(); cursor.advance()) {
agg.aggregate();
}
return agg;
});
return aggSeq.toList().get(0).getLong();
}
Aggregations