Search in sources :

Example 26 with PostAggregator

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();
}
Also used : FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) PostAggregator(org.apache.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) Test(org.junit.Test)

Example 27 with PostAggregator

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();
}
Also used : FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) PostAggregator(org.apache.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) Test(org.junit.Test)

Example 28 with PostAggregator

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]));
}
Also used : FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) PostAggregator(org.apache.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) HashMap(java.util.HashMap) Aggregator(org.apache.druid.query.aggregation.Aggregator) PostAggregator(org.apache.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) TestDoubleColumnSelectorImpl(org.apache.druid.query.aggregation.TestDoubleColumnSelectorImpl) Test(org.junit.Test)

Example 29 with PostAggregator

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());
}
Also used : FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) PostAggregator(org.apache.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Example 30 with PostAggregator

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());
}
Also used : FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) PostAggregator(org.apache.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) Test(org.junit.Test)

Aggregations

PostAggregator (org.apache.druid.query.aggregation.PostAggregator)135 Test (org.junit.Test)98 FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)48 ConstantPostAggregator (org.apache.druid.query.aggregation.post.ConstantPostAggregator)41 HashMap (java.util.HashMap)29 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)21 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)20 Nullable (javax.annotation.Nullable)16 Aggregator (org.apache.druid.query.aggregation.Aggregator)13 Comparator (java.util.Comparator)12 RexCall (org.apache.calcite.rex.RexCall)11 RexNode (org.apache.calcite.rex.RexNode)11 CountAggregator (org.apache.druid.query.aggregation.CountAggregator)10 ArrayList (java.util.ArrayList)9 TestDoubleColumnSelectorImpl (org.apache.druid.query.aggregation.TestDoubleColumnSelectorImpl)9 Map (java.util.Map)8 DimensionSpec (org.apache.druid.query.dimension.DimensionSpec)8 Function (com.google.common.base.Function)7 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)7 List (java.util.List)6