use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToCDFPostAggregatorTest method emptySketch.
@Test
public void emptySketch() {
final TestDoubleColumnSelectorImpl selector = new TestDoubleColumnSelectorImpl(null);
final Aggregator agg = new DoublesSketchBuildAggregator(selector, 8);
final Map<String, Object> fields = new HashMap<>();
fields.put("sketch", agg.get());
final PostAggregator postAgg = new DoublesSketchToCDFPostAggregator("cdf", new FieldAccessPostAggregator("field", "sketch"), new double[] { 4 });
final double[] histogram = (double[]) postAgg.compute(fields);
Assert.assertNotNull(histogram);
Assert.assertEquals(2, histogram.length);
Assert.assertTrue(Double.isNaN(histogram[0]));
Assert.assertTrue(Double.isNaN(histogram[1]));
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilePostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new DoublesSketchToQuantilePostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), 0.5);
DefaultObjectMapper mapper = new DefaultObjectMapper();
DoublesSketchToQuantilePostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), DoublesSketchToQuantilePostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class HllSketchToEstimatePostAggregatorTest method testToString.
@Test
public void testToString() {
final PostAggregator postAgg = new HllSketchToEstimatePostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), true);
Assert.assertEquals("HllSketchToEstimatePostAggregator{name='post', field=FieldAccessPostAggregator{name='field1', fieldName='sketch'}, round=true}", postAgg.toString());
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class HllSketchToEstimatePostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new HllSketchToEstimatePostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), true);
DefaultObjectMapper mapper = new DefaultObjectMapper();
HllSketchToEstimatePostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), HllSketchToEstimatePostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class SketchSetPostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
List<PostAggregator> fields = Arrays.asList(new FieldAccessPostAggregator("field1", "sketch"), new FieldAccessPostAggregator("field2", "sketch"));
final PostAggregator union = new SketchSetPostAggregator("summary", "UNION", null, fields);
final PostAggregator intersect = new SketchSetPostAggregator("summary", "INTERSECT", null, fields);
final PostAggregator not = new SketchSetPostAggregator("summary", "NOT", null, fields);
List<PostAggregator> serdeTests = Arrays.asList(union, intersect, not);
for (PostAggregator there : serdeTests) {
DefaultObjectMapper mapper = new DefaultObjectMapper();
SketchSetPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), SketchSetPostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
}
Aggregations