Search in sources :

Example 51 with ResultRow

use of org.apache.druid.query.groupby.ResultRow in project druid by druid-io.

the class HllSketchAggregatorTest method roundMergeSketch.

@Test
public void roundMergeSketch() throws Exception {
    Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(new File(this.getClass().getClassLoader().getResource("hll/hll_sketches.tsv").getFile()), buildParserJson(Arrays.asList("dim", "multiDim"), Arrays.asList("timestamp", "dim", "multiDim", "sketch")), buildAggregatorJson("HLLSketchMerge", "sketch", ROUND), // minTimestamp
    0, Granularities.NONE, // maxRowCount
    200, buildGroupByQueryJson("HLLSketchMerge", "sketch", ROUND));
    List<ResultRow> results = seq.toList();
    Assert.assertEquals(1, results.size());
    ResultRow row = results.get(0);
    Assert.assertEquals(200L, (long) row.get(0));
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) File(java.io.File) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 52 with ResultRow

use of org.apache.druid.query.groupby.ResultRow in project druid by druid-io.

the class HllSketchAggregatorTest method buildSketchesAtQueryTimeMultiValue.

@Test
public void buildSketchesAtQueryTimeMultiValue() throws Exception {
    Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(new File(this.getClass().getClassLoader().getResource("hll/hll_raw.tsv").getFile()), buildParserJson(Arrays.asList("dim", "multiDim", "id"), Arrays.asList("timestamp", "dim", "multiDim", "id")), "[]", // minTimestamp
    0, Granularities.NONE, // maxRowCount
    200, buildGroupByQueryJson("HLLSketchBuild", "multiDim", !ROUND));
    List<ResultRow> results = seq.toList();
    Assert.assertEquals(1, results.size());
    ResultRow row = results.get(0);
    Assert.assertEquals(14, (double) row.get(0), 0.1);
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) File(java.io.File) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 53 with ResultRow

use of org.apache.druid.query.groupby.ResultRow in project druid by druid-io.

the class HllSketchAggregatorTest method ingestSketches.

@Test
public void ingestSketches() throws Exception {
    Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(new File(this.getClass().getClassLoader().getResource("hll/hll_sketches.tsv").getFile()), buildParserJson(Arrays.asList("dim", "multiDim"), Arrays.asList("timestamp", "dim", "multiDim", "sketch")), buildAggregatorJson("HLLSketchMerge", "sketch", !ROUND), // minTimestamp
    0, Granularities.NONE, // maxRowCount
    200, buildGroupByQueryJson("HLLSketchMerge", "sketch", !ROUND));
    List<ResultRow> results = seq.toList();
    Assert.assertEquals(1, results.size());
    ResultRow row = results.get(0);
    Assert.assertEquals(200, (double) row.get(0), 0.1);
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) File(java.io.File) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 54 with ResultRow

use of org.apache.druid.query.groupby.ResultRow in project druid by druid-io.

the class HllSketchAggregatorTest method roundBuildSketch.

@Test
public void roundBuildSketch() throws Exception {
    Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(new File(this.getClass().getClassLoader().getResource("hll/hll_raw.tsv").getFile()), buildParserJson(Arrays.asList("dim", "multiDim", "id"), Arrays.asList("timestamp", "dim", "multiDim", "id")), "[]", // minTimestamp
    0, Granularities.NONE, // maxRowCount
    200, buildGroupByQueryJson("HLLSketchBuild", "id", ROUND));
    List<ResultRow> results = seq.toList();
    Assert.assertEquals(1, results.size());
    ResultRow row = results.get(0);
    Assert.assertEquals(200L, (long) row.get(0));
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) File(java.io.File) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 55 with ResultRow

use of org.apache.druid.query.groupby.ResultRow in project druid by druid-io.

the class HllSketchAggregatorTest method buildSketchesAtIngestionTime.

@Test
public void buildSketchesAtIngestionTime() throws Exception {
    Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(new File(this.getClass().getClassLoader().getResource("hll/hll_raw.tsv").getFile()), buildParserJson(Collections.singletonList("dim"), Arrays.asList("timestamp", "dim", "multiDim", "id")), buildAggregatorJson("HLLSketchBuild", "id", !ROUND), // minTimestamp
    0, Granularities.NONE, // maxRowCount
    200, buildGroupByQueryJson("HLLSketchMerge", "sketch", !ROUND));
    List<ResultRow> results = seq.toList();
    Assert.assertEquals(1, results.size());
    ResultRow row = results.get(0);
    Assert.assertEquals(200, (double) row.get(0), 0.1);
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) File(java.io.File) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

ResultRow (org.apache.druid.query.groupby.ResultRow)129 Test (org.junit.Test)81 GroupByQueryRunnerTest (org.apache.druid.query.groupby.GroupByQueryRunnerTest)65 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)59 GroupByQuery (org.apache.druid.query.groupby.GroupByQuery)58 File (java.io.File)39 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)37 QueryableIndexSegment (org.apache.druid.segment.QueryableIndexSegment)34 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)24 Benchmark (org.openjdk.jmh.annotations.Benchmark)21 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)21 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)21 IncrementalIndexSegment (org.apache.druid.segment.IncrementalIndexSegment)20 LegacySegmentSpec (org.apache.druid.query.spec.LegacySegmentSpec)18 List (java.util.List)17 DefaultLimitSpec (org.apache.druid.query.groupby.orderby.DefaultLimitSpec)15 ArrayList (java.util.ArrayList)14 GroupByQueryConfig (org.apache.druid.query.groupby.GroupByQueryConfig)14 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)13 ByteBuffer (java.nio.ByteBuffer)12