Search in sources :

Example 1 with TestColumnSelectorFactory

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);
}
Also used : MapBasedRow(org.apache.druid.data.input.MapBasedRow) TestColumnSelectorFactory(org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) Test(org.junit.Test)

Example 2 with TestColumnSelectorFactory

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);
}
Also used : MapBasedRow(org.apache.druid.data.input.MapBasedRow) TestColumnSelectorFactory(org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory) SketchHolder(org.apache.druid.query.aggregation.datasketches.theta.SketchHolder) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 3 with TestColumnSelectorFactory

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();
    }
}
Also used : MapBasedRow(org.apache.druid.data.input.MapBasedRow) TestColumnSelectorFactory(org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.junit.Test)

Aggregations

UpdateSketch (org.apache.datasketches.theta.UpdateSketch)3 MapBasedRow (org.apache.druid.data.input.MapBasedRow)3 TestColumnSelectorFactory (org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory)3 Test (org.junit.Test)3 GroupByQueryRunnerTest (org.apache.druid.query.groupby.GroupByQueryRunnerTest)2 SketchHolder (org.apache.druid.query.aggregation.datasketches.theta.SketchHolder)1 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1