use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToHistogramPostAggregatorTest method testComparator.
@Test
public void testComparator() {
expectedException.expect(IAE.class);
expectedException.expectMessage("Comparing histograms is not supported");
final PostAggregator postAgg = new DoublesSketchToHistogramPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), new double[] { 0.25, 0.75 }, null);
postAgg.getComparator();
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method testComparator.
@Test
public void testComparator() {
expectedException.expect(IAE.class);
expectedException.expectMessage("Comparing arrays of quantiles is not supported");
final PostAggregator postAgg = new DoublesSketchToQuantilesPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), new double[] { 0, 0.5, 1 });
postAgg.getComparator();
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest 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 DoublesSketchToQuantilesPostAggregator("quantiles", new FieldAccessPostAggregator("field", "sketch"), new double[] { 0, 0.5, 1 });
final double[] quantiles = (double[]) postAgg.compute(fields);
Assert.assertNotNull(quantiles);
Assert.assertEquals(3, quantiles.length);
Assert.assertTrue(Double.isNaN(quantiles[0]));
Assert.assertTrue(Double.isNaN(quantiles[1]));
Assert.assertTrue(Double.isNaN(quantiles[2]));
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new DoublesSketchToQuantilesPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), new double[] { 0, 0.5, 1 });
DefaultObjectMapper mapper = new DefaultObjectMapper();
DoublesSketchToQuantilesPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), DoublesSketchToQuantilesPostAggregator.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 DoublesSketchToStringPostAggregatorTest method testToString.
@Test
public void testToString() {
final PostAggregator postAgg = new DoublesSketchToStringPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"));
Assert.assertEquals("DoublesSketchToStringPostAggregator{name='post', field=FieldAccessPostAggregator{name='field1', fieldName='sketch'}}", postAgg.toString());
}
Aggregations