use of org.apache.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));
}
use of org.apache.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class DoubleLeastPostAggregatorTest method testCompute.
@Test
public void testCompute() {
final String aggName = "rows";
DoubleLeastPostAggregator leastPostAggregator;
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));
leastPostAggregator = new DoubleLeastPostAggregator("least", postAggregatorList);
Assert.assertEquals(3.0, leastPostAggregator.compute(metricValues));
}
use of org.apache.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class DoubleLeastPostAggregatorTest method testComparator.
@Test
public void testComparator() {
final String aggName = "rows";
DoubleLeastPostAggregator leastPostAggregator;
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));
leastPostAggregator = new DoubleLeastPostAggregator("least", postAggregatorList);
Comparator comp = leastPostAggregator.getComparator();
Object before = leastPostAggregator.compute(metricValues);
agg.aggregate();
agg.aggregate();
agg.aggregate();
metricValues.put(aggName, agg.get());
Object after = leastPostAggregator.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 org.apache.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class FieldAccessPostAggregatorTest method testCompute.
@Test
public void testCompute() {
final String aggName = "rows";
FieldAccessPostAggregator fieldAccessPostAggregator;
fieldAccessPostAggregator = new FieldAccessPostAggregator("To be, or not to be, that is the question:", "rows");
CountAggregator agg = new CountAggregator();
Map<String, Object> metricValues = new HashMap<String, Object>();
metricValues.put(aggName, agg.get());
Assert.assertEquals(new Long(0L), fieldAccessPostAggregator.compute(metricValues));
agg.aggregate();
agg.aggregate();
agg.aggregate();
metricValues.put(aggName, agg.get());
Assert.assertEquals(new Long(3L), fieldAccessPostAggregator.compute(metricValues));
}
use of org.apache.druid.query.aggregation.CountAggregator in project druid by druid-io.
the class LongLeastPostAggregatorTest method testCompute.
@Test
public void testCompute() {
final String aggName = "rows";
LongLeastPostAggregator leastPostAggregator;
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));
leastPostAggregator = new LongLeastPostAggregator("leastPostAggregator", postAggregatorList);
Assert.assertEquals(Long.valueOf(3), leastPostAggregator.compute(metricValues));
}
Aggregations