use of io.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class LongGreatestPostAggregatorTest method testComparator.
@Test
public void testComparator() {
final String aggName = "rows";
LongGreatestPostAggregator greatestPostAggregator;
CountAggregator agg = new CountAggregator();
Map<String, Object> metricValues = new HashMap<String, Object>();
metricValues.put(aggName, agg.get());
List<PostAggregator> postAggregatorList = Lists.newArrayList(new ConstantPostAggregator("roku", 2D), new FieldAccessPostAggregator("rows", aggName));
greatestPostAggregator = new LongGreatestPostAggregator("greatest", postAggregatorList);
Comparator comp = greatestPostAggregator.getComparator();
Object before = greatestPostAggregator.compute(metricValues);
agg.aggregate();
agg.aggregate();
agg.aggregate();
metricValues.put(aggName, agg.get());
Object after = greatestPostAggregator.compute(metricValues);
Assert.assertEquals(-1, comp.compare(before, after));
Assert.assertEquals(0, comp.compare(before, before));
Assert.assertEquals(0, comp.compare(after, after));
Assert.assertEquals(1, comp.compare(after, before));
}
use of io.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class LongGreatestPostAggregatorTest method testCompute.
@Test
public void testCompute() {
final String aggName = "rows";
LongGreatestPostAggregator greatestPostAggregator;
CountAggregator agg = new CountAggregator();
agg.aggregate();
agg.aggregate();
agg.aggregate();
Map<String, Object> metricValues = new HashMap<String, Object>();
metricValues.put(aggName, agg.get());
List<PostAggregator> postAggregatorList = Lists.newArrayList(new ConstantPostAggregator("roku", 6D), new FieldAccessPostAggregator("rows", aggName));
greatestPostAggregator = new LongGreatestPostAggregator("greatest", postAggregatorList);
Assert.assertEquals(Long.valueOf(6), greatestPostAggregator.compute(metricValues));
}
use of io.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class ArithmeticPostAggregatorTest method testComparator.
@Test
public void testComparator() {
final String aggName = "rows";
ArithmeticPostAggregator arithmeticPostAggregator;
CountAggregator agg = new CountAggregator();
Map<String, Object> metricValues = new HashMap<String, Object>();
metricValues.put(aggName, agg.get());
List<PostAggregator> postAggregatorList = Lists.newArrayList(new ConstantPostAggregator("roku", 6D), new FieldAccessPostAggregator("rows", "rows"));
arithmeticPostAggregator = new ArithmeticPostAggregator("add", "+", postAggregatorList);
Comparator comp = arithmeticPostAggregator.getComparator();
Object before = arithmeticPostAggregator.compute(metricValues);
agg.aggregate();
agg.aggregate();
agg.aggregate();
metricValues.put(aggName, agg.get());
Object after = arithmeticPostAggregator.compute(metricValues);
Assert.assertEquals(-1, comp.compare(before, after));
Assert.assertEquals(0, comp.compare(before, before));
Assert.assertEquals(0, comp.compare(after, after));
Assert.assertEquals(1, comp.compare(after, before));
}
use of io.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class DoubleGreatestPostAggregatorTest method testCompute.
@Test
public void testCompute() {
final String aggName = "rows";
DoubleGreatestPostAggregator greatestPostAggregator;
CountAggregator agg = new CountAggregator();
agg.aggregate();
agg.aggregate();
agg.aggregate();
Map<String, Object> metricValues = new HashMap<String, Object>();
metricValues.put(aggName, agg.get());
List<PostAggregator> postAggregatorList = Lists.newArrayList(new ConstantPostAggregator("roku", 6D), new FieldAccessPostAggregator("rows", aggName));
greatestPostAggregator = new DoubleGreatestPostAggregator("greatest", postAggregatorList);
Assert.assertEquals(6.0, greatestPostAggregator.compute(metricValues));
}
use of io.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class DoubleGreatestPostAggregatorTest method testComparator.
@Test
public void testComparator() {
final String aggName = "rows";
DoubleGreatestPostAggregator greatestPostAggregator;
CountAggregator agg = new CountAggregator();
Map<String, Object> metricValues = new HashMap<String, Object>();
metricValues.put(aggName, agg.get());
List<PostAggregator> postAggregatorList = Lists.newArrayList(new ConstantPostAggregator("roku", 2D), new FieldAccessPostAggregator("rows", aggName));
greatestPostAggregator = new DoubleGreatestPostAggregator("greatest", postAggregatorList);
Comparator comp = greatestPostAggregator.getComparator();
Object before = greatestPostAggregator.compute(metricValues);
agg.aggregate();
agg.aggregate();
agg.aggregate();
metricValues.put(aggName, agg.get());
Object after = greatestPostAggregator.compute(metricValues);
Assert.assertEquals(-1, comp.compare(before, after));
Assert.assertEquals(0, comp.compare(before, before));
Assert.assertEquals(0, comp.compare(after, after));
Assert.assertEquals(1, comp.compare(after, before));
}
Aggregations