Search in sources :

Example 11 with QueryToolChest

use of io.druid.query.QueryToolChest in project druid by druid-io.

the class SearchBenchmark method queryMultiQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole) throws Exception {
    List<QueryRunner<Row>> singleSegmentRunners = Lists.newArrayList();
    QueryToolChest toolChest = factory.getToolchest();
    for (int i = 0; i < numSegments; i++) {
        String segmentName = "qIndex" + i;
        final QueryRunner<Result<SearchResultValue>> 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<SearchResultValue>> queryResult = theRunner.run(query, Maps.<String, Object>newHashMap());
    List<Result<SearchResultValue>> results = Sequences.toList(queryResult, Lists.<Result<SearchResultValue>>newArrayList());
    for (Result<SearchResultValue> result : results) {
        List<SearchHit> hits = result.getValue().getValue();
        for (SearchHit hit : hits) {
            blackhole.consume(hit);
        }
    }
}
Also used : QueryableIndexSegment(io.druid.segment.QueryableIndexSegment) SearchHit(io.druid.query.search.search.SearchHit) SearchQueryQueryToolChest(io.druid.query.search.SearchQueryQueryToolChest) QueryToolChest(io.druid.query.QueryToolChest) FinalizeResultsQueryRunner(io.druid.query.FinalizeResultsQueryRunner) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) SearchResultValue(io.druid.query.search.SearchResultValue) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 12 with QueryToolChest

use of io.druid.query.QueryToolChest in project druid by druid-io.

the class SelectBenchmark method queryMultiQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole) throws Exception {
    SelectQuery queryCopy = query.withPagingSpec(PagingSpec.newSpec(pagingThreshold));
    String segmentName;
    List<QueryRunner<Result<SelectResultValue>>> singleSegmentRunners = Lists.newArrayList();
    QueryToolChest toolChest = factory.getToolchest();
    for (int i = 0; i < numSegments; i++) {
        segmentName = "qIndex" + i;
        QueryRunner<Result<SelectResultValue>> 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));
    boolean done = false;
    while (!done) {
        Sequence<Result<SelectResultValue>> queryResult = theRunner.run(queryCopy, Maps.<String, Object>newHashMap());
        List<Result<SelectResultValue>> results = Sequences.toList(queryResult, Lists.<Result<SelectResultValue>>newArrayList());
        SelectResultValue result = results.get(0).getValue();
        if (result.getEvents().size() == 0) {
            done = true;
        } else {
            for (EventHolder eh : result.getEvents()) {
                blackhole.consume(eh);
            }
            queryCopy = incrementQueryPagination(queryCopy, result);
        }
    }
}
Also used : QueryableIndexSegment(io.druid.segment.QueryableIndexSegment) SelectResultValue(io.druid.query.select.SelectResultValue) SelectQueryQueryToolChest(io.druid.query.select.SelectQueryQueryToolChest) QueryToolChest(io.druid.query.QueryToolChest) FinalizeResultsQueryRunner(io.druid.query.FinalizeResultsQueryRunner) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) SelectQuery(io.druid.query.select.SelectQuery) EventHolder(io.druid.query.select.EventHolder) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 13 with QueryToolChest

use of io.druid.query.QueryToolChest in project druid by druid-io.

the class TopNBenchmark method runQuery.

private static <T> List<T> runQuery(QueryRunnerFactory factory, QueryRunner runner, Query<T> query) {
    QueryToolChest toolChest = factory.getToolchest();
    QueryRunner<T> theRunner = new FinalizeResultsQueryRunner<>(toolChest.mergeResults(toolChest.preMergeQueryDecoration(runner)), toolChest);
    Sequence<T> queryResult = theRunner.run(query, Maps.<String, Object>newHashMap());
    return Sequences.toList(queryResult, Lists.<T>newArrayList());
}
Also used : FinalizeResultsQueryRunner(io.druid.query.FinalizeResultsQueryRunner) TopNQueryQueryToolChest(io.druid.query.topn.TopNQueryQueryToolChest) QueryToolChest(io.druid.query.QueryToolChest)

Example 14 with QueryToolChest

use of io.druid.query.QueryToolChest in project druid by druid-io.

the class CachingQueryRunnerTest method testTimeseries.

@Test
public void testTimeseries() throws Exception {
    for (boolean descending : new boolean[] { false, true }) {
        TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.dayGran).intervals(QueryRunnerTestHelper.firstToThird).aggregators(Arrays.<AggregatorFactory>asList(QueryRunnerTestHelper.rowsCount, new LongSumAggregatorFactory("idx", "index"), QueryRunnerTestHelper.qualityUniques)).descending(descending).build();
        Result row1 = new Result(new DateTime("2011-04-01"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 13L, "idx", 6619L, "uniques", QueryRunnerTestHelper.UNIQUES_9)));
        Result row2 = new Result<>(new DateTime("2011-04-02"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 13L, "idx", 5827L, "uniques", QueryRunnerTestHelper.UNIQUES_9)));
        List<Result> expectedResults;
        if (descending) {
            expectedResults = Lists.newArrayList(row2, row1);
        } else {
            expectedResults = Lists.newArrayList(row1, row2);
        }
        QueryToolChest toolChest = new TimeseriesQueryQueryToolChest(QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator());
        testCloseAndPopulate(expectedResults, expectedResults, query, toolChest);
        testUseCache(expectedResults, query, toolChest);
    }
}
Also used : TimeseriesResultValue(io.druid.query.timeseries.TimeseriesResultValue) TimeseriesQuery(io.druid.query.timeseries.TimeseriesQuery) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) TopNQueryQueryToolChest(io.druid.query.topn.TopNQueryQueryToolChest) TimeseriesQueryQueryToolChest(io.druid.query.timeseries.TimeseriesQueryQueryToolChest) QueryToolChest(io.druid.query.QueryToolChest) TimeseriesQueryQueryToolChest(io.druid.query.timeseries.TimeseriesQueryQueryToolChest) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Example 15 with QueryToolChest

use of io.druid.query.QueryToolChest in project druid by druid-io.

the class CachingQueryRunnerTest method testCloseAndPopulate.

@Test
public void testCloseAndPopulate() throws Exception {
    List<Result> expectedRes = makeTopNResults(false, objects);
    List<Result> expectedCacheRes = makeTopNResults(true, objects);
    TopNQueryBuilder builder = new TopNQueryBuilder().dataSource("ds").dimension("top_dim").metric("imps").threshold(3).intervals("2011-01-05/2011-01-10").aggregators(AGGS).granularity(Granularities.ALL);
    QueryToolChest toolchest = new TopNQueryQueryToolChest(new TopNQueryConfig(), QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator());
    testCloseAndPopulate(expectedRes, expectedCacheRes, builder.build(), toolchest);
    testUseCache(expectedCacheRes, builder.build(), toolchest);
}
Also used : TopNQueryBuilder(io.druid.query.topn.TopNQueryBuilder) TopNQueryConfig(io.druid.query.topn.TopNQueryConfig) TopNQueryQueryToolChest(io.druid.query.topn.TopNQueryQueryToolChest) TopNQueryQueryToolChest(io.druid.query.topn.TopNQueryQueryToolChest) TimeseriesQueryQueryToolChest(io.druid.query.timeseries.TimeseriesQueryQueryToolChest) QueryToolChest(io.druid.query.QueryToolChest) Result(io.druid.query.Result) Test(org.junit.Test)

Aggregations

QueryToolChest (io.druid.query.QueryToolChest)32 FinalizeResultsQueryRunner (io.druid.query.FinalizeResultsQueryRunner)27 QueryRunner (io.druid.query.QueryRunner)20 Test (org.junit.Test)15 Result (io.druid.query.Result)13 ExecutorService (java.util.concurrent.ExecutorService)13 SegmentAnalysis (io.druid.query.metadata.metadata.SegmentAnalysis)9 ColumnAnalysis (io.druid.query.metadata.metadata.ColumnAnalysis)8 ListColumnIncluderator (io.druid.query.metadata.metadata.ListColumnIncluderator)8 DateTime (org.joda.time.DateTime)7 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)6 TimeseriesQueryQueryToolChest (io.druid.query.timeseries.TimeseriesQueryQueryToolChest)6 BySegmentResultValue (io.druid.query.BySegmentResultValue)5 BySegmentResultValueClass (io.druid.query.BySegmentResultValueClass)5 Query (io.druid.query.Query)5 TopNQueryQueryToolChest (io.druid.query.topn.TopNQueryQueryToolChest)5 PeriodGranularity (io.druid.java.util.common.granularity.PeriodGranularity)4 SelectorDimFilter (io.druid.query.filter.SelectorDimFilter)4 QueryableIndexSegment (io.druid.segment.QueryableIndexSegment)4 Interval (org.joda.time.Interval)4