Search in sources :

Example 71 with PostAggregator

use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.

the class MomentSketchMinPostAggregatorTest method testToString.

@Test
public void testToString() {
    PostAggregator postAgg = new MomentSketchMinPostAggregator("post", new ConstantPostAggregator("", 100));
    Assert.assertEquals("MomentSketchMinPostAggregator{name='post', field=ConstantPostAggregator{name='', constantValue=100}}", postAgg.toString());
}
Also used : PostAggregator(org.apache.druid.query.aggregation.PostAggregator) ConstantPostAggregator(org.apache.druid.query.aggregation.post.ConstantPostAggregator) ConstantPostAggregator(org.apache.druid.query.aggregation.post.ConstantPostAggregator) Test(org.junit.Test)

Example 72 with PostAggregator

use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.

the class MomentSketchMaxPostAggregatorTest method testToString.

@Test
public void testToString() {
    PostAggregator postAgg = new MomentSketchMaxPostAggregator("post", new ConstantPostAggregator("", 100));
    Assert.assertEquals("MomentSketchMaxPostAggregator{name='post', field=ConstantPostAggregator{name='', constantValue=100}}", postAgg.toString());
}
Also used : PostAggregator(org.apache.druid.query.aggregation.PostAggregator) ConstantPostAggregator(org.apache.druid.query.aggregation.post.ConstantPostAggregator) ConstantPostAggregator(org.apache.druid.query.aggregation.post.ConstantPostAggregator) Test(org.junit.Test)

Example 73 with PostAggregator

use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.

the class SketchSetPostAggregatorTest method testComparator.

@Test
public void testComparator() {
    Union u1 = (Union) SetOperation.builder().setNominalEntries(10).build(Family.UNION);
    u1.update(10L);
    Union u2 = (Union) SetOperation.builder().setNominalEntries(10).build(Family.UNION);
    u2.update(20L);
    Union u3 = (Union) SetOperation.builder().setNominalEntries(10).build(Family.UNION);
    u3.update(10L);
    Union u4 = (Union) SetOperation.builder().setNominalEntries(10).build(Family.UNION);
    u4.update(20L);
    PostAggregator field1 = EasyMock.createMock(PostAggregator.class);
    EasyMock.expect(field1.compute(EasyMock.anyObject(Map.class))).andReturn(SketchHolder.of(u1)).anyTimes();
    PostAggregator field2 = EasyMock.createMock(PostAggregator.class);
    EasyMock.expect(field2.compute(EasyMock.anyObject(Map.class))).andReturn(SketchHolder.of(u2)).anyTimes();
    PostAggregator field3 = EasyMock.createMock(PostAggregator.class);
    EasyMock.expect(field3.compute(EasyMock.anyObject(Map.class))).andReturn(SketchHolder.of(u3)).anyTimes();
    PostAggregator field4 = EasyMock.createMock(PostAggregator.class);
    EasyMock.expect(field4.compute(EasyMock.anyObject(Map.class))).andReturn(SketchHolder.of(u4)).anyTimes();
    EasyMock.replay(field1, field2, field3, field4);
    SketchSetPostAggregator postAgg1 = new SketchSetPostAggregator("summary", "UNION", null, Arrays.asList(field1, field2));
    SketchSetPostAggregator postAgg2 = new SketchSetPostAggregator("summary", "UNION", null, Arrays.asList(field3, field4));
    SketchHolder holder1 = (SketchHolder) postAgg1.compute(ImmutableMap.of());
    SketchHolder holder2 = (SketchHolder) postAgg2.compute(ImmutableMap.of());
    Assert.assertEquals(0, postAgg1.getComparator().compare(holder1, holder2));
}
Also used : PostAggregator(org.apache.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) Union(org.apache.datasketches.theta.Union) Test(org.junit.Test)

Example 74 with PostAggregator

use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.

the class HllSketchToStringPostAggregatorTest method testSerde.

@Test
public void testSerde() throws JsonProcessingException {
    final PostAggregator there = new HllSketchToStringPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"));
    DefaultObjectMapper mapper = new DefaultObjectMapper();
    HllSketchToStringPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), HllSketchToStringPostAggregator.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 75 with PostAggregator

use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.

the class HllSketchToStringPostAggregatorTest method testToString.

@Test
public void testToString() {
    final PostAggregator postAgg = new HllSketchToStringPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"));
    Assert.assertEquals("HllSketchToStringPostAggregator{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