use of org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory in project druid by druid-io.
the class SketchAggregationTest method testRelocation.
@Test
public void testRelocation() {
final TestColumnSelectorFactory columnSelectorFactory = GrouperTestUtil.newColumnSelectorFactory();
SketchHolder sketchHolder = SketchHolder.of(Sketches.updateSketchBuilder().setNominalEntries(16).build());
UpdateSketch updateSketch = (UpdateSketch) sketchHolder.getSketch();
updateSketch.update(1);
columnSelectorFactory.setRow(new MapBasedRow(0, ImmutableMap.of("sketch", sketchHolder)));
SketchHolder[] holders = helper.runRelocateVerificationTest(new SketchMergeAggregatorFactory("sketch", "sketch", 16, false, true, 2), columnSelectorFactory, SketchHolder.class);
Assert.assertEquals(holders[0].getEstimate(), holders[1].getEstimate(), 0);
}
use of org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory in project druid by druid-io.
the class OldApiSketchAggregationTest method testRelocation.
@Test
public void testRelocation() {
final TestColumnSelectorFactory columnSelectorFactory = GrouperTestUtil.newColumnSelectorFactory();
SketchHolder sketchHolder = SketchHolder.of(Sketches.updateSketchBuilder().setNominalEntries(16).build());
UpdateSketch updateSketch = (UpdateSketch) sketchHolder.getSketch();
updateSketch.update(1);
columnSelectorFactory.setRow(new MapBasedRow(0, ImmutableMap.of("sketch", sketchHolder)));
SketchHolder[] holders = helper.runRelocateVerificationTest(new OldSketchMergeAggregatorFactory("sketch", "sketch", 16, false), columnSelectorFactory, SketchHolder.class);
Assert.assertEquals(holders[0].getEstimate(), holders[1].getEstimate(), 0);
}
use of org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory in project druid by druid-io.
the class BufferHashGrouperUsingSketchMergeAggregatorFactoryTest method testGrowingBufferGrouper.
@Test
public void testGrowingBufferGrouper() {
final TestColumnSelectorFactory columnSelectorFactory = GrouperTestUtil.newColumnSelectorFactory();
final Grouper<Integer> grouper = makeGrouper(columnSelectorFactory, 100000, 2);
try {
final int expectedMaxSize = 5;
SketchHolder sketchHolder = SketchHolder.of(Sketches.updateSketchBuilder().setNominalEntries(16).build());
UpdateSketch updateSketch = (UpdateSketch) sketchHolder.getSketch();
updateSketch.update(1);
columnSelectorFactory.setRow(new MapBasedRow(0, ImmutableMap.of("sketch", sketchHolder)));
for (int i = 0; i < expectedMaxSize; i++) {
Assert.assertTrue(String.valueOf(i), grouper.aggregate(i).isOk());
}
updateSketch.update(3);
columnSelectorFactory.setRow(new MapBasedRow(0, ImmutableMap.of("sketch", sketchHolder)));
for (int i = 0; i < expectedMaxSize; i++) {
Assert.assertTrue(String.valueOf(i), grouper.aggregate(i).isOk());
}
Object[] holders = Lists.newArrayList(grouper.iterator(true)).get(0).getValues();
Assert.assertEquals(2.0d, ((SketchHolder) holders[0]).getEstimate(), 0);
} finally {
grouper.close();
}
}
Aggregations