Search in sources :

Example 6 with TopNResultValue

use of org.apache.druid.query.topn.TopNResultValue in project druid by druid-io.

the class SketchAggregationWithSimpleDataTest method testSimpleDataIngestAndTopNQuery.

@Test
public void testSimpleDataIngestAndTopNQuery() throws Exception {
    AggregationTestHelper topNQueryAggregationTestHelper = AggregationTestHelper.createTopNQueryAggregationTestHelper(sm.getJacksonModules(), tempFolder);
    Sequence seq = topNQueryAggregationTestHelper.runQueryOnSegments(ImmutableList.of(s1, s2), (Query) SketchAggregationTest.readQueryFromClasspath("topn_query.json", topNQueryAggregationTestHelper.getObjectMapper(), vectorize));
    Result<TopNResultValue> result = (Result<TopNResultValue>) Iterables.getOnlyElement(seq.toList());
    Assert.assertEquals(DateTimes.of("2014-10-20T00:00:00.000Z"), result.getTimestamp());
    DimensionAndMetricValueExtractor value = Iterables.getOnlyElement(result.getValue().getValue());
    Assert.assertEquals(38.0, value.getDoubleMetric("sketch_count"), 0.01);
    Assert.assertEquals(38.0, value.getDoubleMetric("sketchEstimatePostAgg"), 0.01);
    Assert.assertEquals(38.0, value.getDoubleMetric("sketchUnionPostAggEstimate"), 0.01);
    Assert.assertEquals(38.0, value.getDoubleMetric("sketchIntersectionPostAggEstimate"), 0.01);
    Assert.assertEquals(0.0, value.getDoubleMetric("sketchAnotBPostAggEstimate"), 0.01);
    Assert.assertEquals(0.0, value.getDoubleMetric("non_existing_col_validation"), 0.01);
    Assert.assertEquals("product_3", value.getDimensionValue("product"));
}
Also used : TopNResultValue(org.apache.druid.query.topn.TopNResultValue) AggregationTestHelper(org.apache.druid.query.aggregation.AggregationTestHelper) Sequence(org.apache.druid.java.util.common.guava.Sequence) DimensionAndMetricValueExtractor(org.apache.druid.query.topn.DimensionAndMetricValueExtractor) Result(org.apache.druid.query.Result) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 7 with TopNResultValue

use of org.apache.druid.query.topn.TopNResultValue in project druid by druid-io.

the class CachingClusteredClientBenchmark method topNQuery.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void topNQuery(Blackhole blackhole) {
    query = new TopNQueryBuilder().dataSource(DATA_SOURCE).intervals(basicSchemaIntervalSpec).dimension(new DefaultDimensionSpec("dimZipf", null)).aggregators(new LongSumAggregatorFactory("sumLongSequential", "sumLongSequential")).granularity(Granularity.fromString(queryGranularity)).metric("sumLongSequential").threshold(// we are primarily measuring 'broker' merge time, so collect a significant number of results
    10_000).context(ImmutableMap.of(QueryContexts.BROKER_PARALLEL_MERGE_KEY, parallelCombine, QueryContexts.BROKER_PARALLELISM, parallelism)).build();
    final List<Result<TopNResultValue>> results = runQuery();
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
}
Also used : TopNQueryBuilder(org.apache.druid.query.topn.TopNQueryBuilder) TopNResultValue(org.apache.druid.query.topn.TopNResultValue) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) Result(org.apache.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 8 with TopNResultValue

use of org.apache.druid.query.topn.TopNResultValue in project druid by druid-io.

the class TopNTypeInterfaceBenchmark method querySingleQueryableIndexStringOnly.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexStringOnly(Blackhole blackhole) {
    QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, Q_INDEX_SEGMENT_ID, new QueryableIndexSegment(qIndexes.get(0), Q_INDEX_SEGMENT_ID));
    List<Result<TopNResultValue>> results = TopNTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
}
Also used : QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) TopNResultValue(org.apache.druid.query.topn.TopNResultValue) Result(org.apache.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 9 with TopNResultValue

use of org.apache.druid.query.topn.TopNResultValue in project druid by druid-io.

the class TopNTypeInterfaceBenchmark method querySingleQueryableIndexFloatThenString.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexFloatThenString(Blackhole blackhole) {
    QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, Q_INDEX_SEGMENT_ID, new QueryableIndexSegment(qIndexes.get(0), Q_INDEX_SEGMENT_ID));
    List<Result<TopNResultValue>> results = TopNTypeInterfaceBenchmark.runQuery(factory, runner, floatQuery);
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
    runner = QueryBenchmarkUtil.makeQueryRunner(factory, Q_INDEX_SEGMENT_ID, new QueryableIndexSegment(qIndexes.get(0), Q_INDEX_SEGMENT_ID));
    results = TopNTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
}
Also used : QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) TopNResultValue(org.apache.druid.query.topn.TopNResultValue) Result(org.apache.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 10 with TopNResultValue

use of org.apache.druid.query.topn.TopNResultValue in project druid by druid-io.

the class TopNTypeInterfaceBenchmark method querySingleQueryableIndexStringThenLong.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexStringThenLong(Blackhole blackhole) {
    QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, Q_INDEX_SEGMENT_ID, new QueryableIndexSegment(qIndexes.get(0), Q_INDEX_SEGMENT_ID));
    List<Result<TopNResultValue>> results = TopNTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
    runner = QueryBenchmarkUtil.makeQueryRunner(factory, Q_INDEX_SEGMENT_ID, new QueryableIndexSegment(qIndexes.get(0), Q_INDEX_SEGMENT_ID));
    results = TopNTypeInterfaceBenchmark.runQuery(factory, runner, longQuery);
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
}
Also used : QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) TopNResultValue(org.apache.druid.query.topn.TopNResultValue) Result(org.apache.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

TopNResultValue (org.apache.druid.query.topn.TopNResultValue)32 Result (org.apache.druid.query.Result)28 QueryableIndexSegment (org.apache.druid.segment.QueryableIndexSegment)17 Benchmark (org.openjdk.jmh.annotations.Benchmark)14 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)14 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)14 TopNQueryBuilder (org.apache.druid.query.topn.TopNQueryBuilder)11 Test (org.junit.Test)11 TopNQuery (org.apache.druid.query.topn.TopNQuery)10 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)9 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)7 Map (java.util.Map)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 ArrayList (java.util.ArrayList)5 TopNQueryQueryToolChest (org.apache.druid.query.topn.TopNQueryQueryToolChest)5 ByteBuffer (java.nio.ByteBuffer)4 HashMap (java.util.HashMap)4 Sequence (org.apache.druid.java.util.common.guava.Sequence)4 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)4 GroupByQueryRunnerTest (org.apache.druid.query.groupby.GroupByQueryRunnerTest)4