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());
}
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());
}
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));
}
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());
}
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());
}
Aggregations