Search in sources :

Example 16 with TopNResultValue

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

the class TopNBenchmark method querySingleIncrementalIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleIncrementalIndex(Blackhole blackhole) throws Exception {
    QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "incIndex", new IncrementalIndexSegment(incIndexes.get(0), "incIndex"));
    List<Result<TopNResultValue>> results = TopNBenchmark.runQuery(factory, runner, query);
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
}
Also used : TopNResultValue(io.druid.query.topn.TopNResultValue) IncrementalIndexSegment(io.druid.segment.IncrementalIndexSegment) Result(io.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 17 with TopNResultValue

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

the class TopNBenchmark method querySingleQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndex(Blackhole blackhole) throws Exception {
    final QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex", new QueryableIndexSegment("qIndex", qIndexes.get(0)));
    List<Result<TopNResultValue>> results = TopNBenchmark.runQuery(factory, runner, query);
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
}
Also used : QueryableIndexSegment(io.druid.segment.QueryableIndexSegment) TopNResultValue(io.druid.query.topn.TopNResultValue) Result(io.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 18 with TopNResultValue

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

the class TopNBenchmark method queryMultiQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole) throws Exception {
    List<QueryRunner<Result<TopNResultValue>>> singleSegmentRunners = Lists.newArrayList();
    QueryToolChest toolChest = factory.getToolchest();
    for (int i = 0; i < numSegments; i++) {
        String segmentName = "qIndex" + i;
        QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, segmentName, new QueryableIndexSegment(segmentName, qIndexes.get(i)));
        singleSegmentRunners.add(toolChest.preMergeQueryDecoration(runner));
    }
    QueryRunner theRunner = toolChest.postMergeQueryDecoration(new FinalizeResultsQueryRunner<>(toolChest.mergeResults(factory.mergeRunners(executorService, singleSegmentRunners)), toolChest));
    Sequence<Result<TopNResultValue>> queryResult = theRunner.run(query, Maps.<String, Object>newHashMap());
    List<Result<TopNResultValue>> results = Sequences.toList(queryResult, Lists.<Result<TopNResultValue>>newArrayList());
    for (Result<TopNResultValue> result : results) {
        blackhole.consume(result);
    }
}
Also used : TopNResultValue(io.druid.query.topn.TopNResultValue) QueryableIndexSegment(io.druid.segment.QueryableIndexSegment) TopNQueryQueryToolChest(io.druid.query.topn.TopNQueryQueryToolChest) QueryToolChest(io.druid.query.QueryToolChest) FinalizeResultsQueryRunner(io.druid.query.FinalizeResultsQueryRunner) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 19 with TopNResultValue

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

the class SchemalessTestFullTest method testFilteredTopN.

private void testFilteredTopN(QueryRunner runner, List<Result<TopNResultValue>> expectedResults, String failMsg) {
    TopNQuery query = new TopNQueryBuilder().dataSource(dataSource).granularity(allGran).dimension(marketDimension).filters(marketDimension, "spot").metric(indexMetric).threshold(3).intervals(fullOnInterval).aggregators(Lists.<AggregatorFactory>newArrayList(Iterables.concat(commonAggregators, Lists.newArrayList(new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"))))).postAggregators(Arrays.<PostAggregator>asList(addRowsIndexConstant)).build();
    failMsg += " filtered topN ";
    HashMap<String, Object> context = new HashMap<>();
    Iterable<Result<TopNResultValue>> actualResults = Sequences.toList(runner.run(query, context), Lists.<Result<TopNResultValue>>newArrayList());
    TestHelper.assertExpectedResults(expectedResults, actualResults, failMsg);
}
Also used : TopNQueryBuilder(io.druid.query.topn.TopNQueryBuilder) TopNResultValue(io.druid.query.topn.TopNResultValue) DoubleMaxAggregatorFactory(io.druid.query.aggregation.DoubleMaxAggregatorFactory) PostAggregator(io.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(io.druid.query.aggregation.post.FieldAccessPostAggregator) ArithmeticPostAggregator(io.druid.query.aggregation.post.ArithmeticPostAggregator) ConstantPostAggregator(io.druid.query.aggregation.post.ConstantPostAggregator) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TopNQuery(io.druid.query.topn.TopNQuery) DoubleMinAggregatorFactory(io.druid.query.aggregation.DoubleMinAggregatorFactory) Result(io.druid.query.Result)

Example 20 with TopNResultValue

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

the class SchemalessTestFullTest method testFullOnTopN.

private void testFullOnTopN(QueryRunner runner, List<Result<TopNResultValue>> expectedResults, String failMsg) {
    TopNQuery query = new TopNQueryBuilder().dataSource(dataSource).granularity(allGran).dimension(marketDimension).metric(indexMetric).threshold(3).intervals(fullOnInterval).aggregators(Lists.<AggregatorFactory>newArrayList(Iterables.concat(commonAggregators, Lists.newArrayList(new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"))))).postAggregators(Arrays.<PostAggregator>asList(addRowsIndexConstant)).build();
    failMsg += " topN ";
    HashMap<String, Object> context = new HashMap<>();
    Iterable<Result<TopNResultValue>> actualResults = Sequences.toList(runner.run(query, context), Lists.<Result<TopNResultValue>>newArrayList());
    TestHelper.assertExpectedResults(expectedResults, actualResults, failMsg);
}
Also used : TopNQueryBuilder(io.druid.query.topn.TopNQueryBuilder) TopNResultValue(io.druid.query.topn.TopNResultValue) DoubleMaxAggregatorFactory(io.druid.query.aggregation.DoubleMaxAggregatorFactory) PostAggregator(io.druid.query.aggregation.PostAggregator) FieldAccessPostAggregator(io.druid.query.aggregation.post.FieldAccessPostAggregator) ArithmeticPostAggregator(io.druid.query.aggregation.post.ArithmeticPostAggregator) ConstantPostAggregator(io.druid.query.aggregation.post.ConstantPostAggregator) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TopNQuery(io.druid.query.topn.TopNQuery) DoubleMinAggregatorFactory(io.druid.query.aggregation.DoubleMinAggregatorFactory) Result(io.druid.query.Result)

Aggregations

TopNResultValue (io.druid.query.topn.TopNResultValue)32 Result (io.druid.query.Result)30 QueryableIndexSegment (io.druid.segment.QueryableIndexSegment)15 Benchmark (org.openjdk.jmh.annotations.Benchmark)15 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)15 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)15 DateTime (org.joda.time.DateTime)14 TopNQuery (io.druid.query.topn.TopNQuery)11 Test (org.junit.Test)11 HashMap (java.util.HashMap)10 TopNQueryBuilder (io.druid.query.topn.TopNQueryBuilder)9 QueryRunner (io.druid.query.QueryRunner)6 DoubleMaxAggregatorFactory (io.druid.query.aggregation.DoubleMaxAggregatorFactory)5 DoubleMinAggregatorFactory (io.druid.query.aggregation.DoubleMinAggregatorFactory)5 PostAggregator (io.druid.query.aggregation.PostAggregator)5 CountAggregatorFactory (io.druid.query.aggregation.CountAggregatorFactory)4 ArithmeticPostAggregator (io.druid.query.aggregation.post.ArithmeticPostAggregator)3 ConstantPostAggregator (io.druid.query.aggregation.post.ConstantPostAggregator)3 FieldAccessPostAggregator (io.druid.query.aggregation.post.FieldAccessPostAggregator)3 GroupByQueryRunnerTest (io.druid.query.groupby.GroupByQueryRunnerTest)3