use of org.apache.datasketches.theta.Union 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));
}
Aggregations