use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method testToString.
@Test
public void testToString() {
final PostAggregator postAgg = new DoublesSketchToQuantilesPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), new double[] { 0, 0.5, 1 });
Assert.assertEquals("DoublesSketchToQuantilesPostAggregator{name='post', field=FieldAccessPostAggregator{name='field1', fieldName='sketch'}, fractions=[0.0, 0.5, 1.0]}", postAgg.toString());
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class HllSketchAggregatorTest method testPostAggs.
@Test
public void testPostAggs() throws Exception {
Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(new File(this.getClass().getClassLoader().getResource("hll/hll_sketches.tsv").getFile()), buildParserJson(Arrays.asList("dim", "multiDim"), Arrays.asList("timestamp", "dim", "multiDim", "sketch")), buildAggregatorJson("HLLSketchMerge", "sketch", ROUND), // minTimestamp
0, Granularities.NONE, // maxRowCount
200, helper.getObjectMapper().writeValueAsString(GroupByQuery.builder().setDataSource("test_datasource").setGranularity(Granularities.ALL).setInterval(Intervals.ETERNITY).setAggregatorSpecs(new HllSketchMergeAggregatorFactory("sketch", "sketch", null, null, false)).setPostAggregatorSpecs(ImmutableList.of(new HllSketchToEstimatePostAggregator("estimate", new FieldAccessPostAggregator("f1", "sketch"), false), new HllSketchToEstimateWithBoundsPostAggregator("estimateWithBounds", new FieldAccessPostAggregator("f1", "sketch"), 2), new HllSketchToStringPostAggregator("summary", new FieldAccessPostAggregator("f1", "sketch")), new HllSketchUnionPostAggregator("union", ImmutableList.of(new FieldAccessPostAggregator("f1", "sketch"), new FieldAccessPostAggregator("f2", "sketch")), null, null))).build()));
final String expectedSummary = "### HLL SKETCH SUMMARY: \n" + " Log Config K : 12\n" + " Hll Target : HLL_4\n" + " Current Mode : SET\n" + " Memory : false\n" + " LB : 200.0\n" + " Estimate : 200.0000988444255\n" + " UB : 200.01008469948434\n" + " OutOfOrder Flag: false\n" + " Coupon Count : 200\n";
List<ResultRow> results = seq.toList();
Assert.assertEquals(1, results.size());
ResultRow row = results.get(0);
Assert.assertEquals(200, (double) row.get(0), 0.1);
Assert.assertEquals(200, (double) row.get(1), 0.1);
Assert.assertArrayEquals(new double[] { 200, 200, 200 }, (double[]) row.get(2), 0.1);
Assert.assertEquals(expectedSummary, row.get(3));
// union with self = self
Assert.assertEquals(expectedSummary, row.get(4).toString());
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class HllSketchToEstimateWithBoundsPostAggregatorTest method testToString.
@Test
public void testToString() {
final PostAggregator postAgg = new HllSketchToEstimateWithBoundsPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), 2);
Assert.assertEquals("HllSketchToEstimateWithBoundsPostAggregator{name='post', field=FieldAccessPostAggregator{name='field1', fieldName='sketch'}, numStdDev=2}", postAgg.toString());
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class HllSketchUnionPostAggregatorTest method testToString.
@Test
public void testToString() {
final PostAggregator postAgg = new HllSketchUnionPostAggregator("post", Arrays.asList(new FieldAccessPostAggregator("field1", "sketch"), new FieldAccessPostAggregator("field2", "sketch")), null, null);
Assert.assertEquals("HllSketchUnionPostAggregator{name='post', fields=[FieldAccessPostAggregator{name='field1', fieldName='sketch'}, FieldAccessPostAggregator{name='field2', fieldName='sketch'}], lgK=12, tgtHllType=HLL_4}", postAgg.toString());
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class HllSketchUnionPostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new HllSketchUnionPostAggregator("post", Arrays.asList(new FieldAccessPostAggregator("field1", "sketch"), new FieldAccessPostAggregator("field2", "sketch")), 1024, TgtHllType.HLL_8.name());
DefaultObjectMapper mapper = new DefaultObjectMapper();
HllSketchUnionPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), HllSketchUnionPostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
Aggregations