Search in sources :

Example 51 with QueryRunner

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

the class GroupByBenchmark method makeMultiRunners.

private List<QueryRunner<ResultRow>> makeMultiRunners(QueryableIndexState state) {
    List<QueryRunner<ResultRow>> runners = new ArrayList<>();
    for (int i = 0; i < state.numSegments; i++) {
        String segmentName = "qIndex " + i;
        QueryRunner<ResultRow> runner = QueryBenchmarkUtil.makeQueryRunner(factory, SegmentId.dummy(segmentName), new QueryableIndexSegment(state.queryableIndexes.get(i), SegmentId.dummy(segmentName)));
        runners.add(factory.getToolchest().preMergeQueryDecoration(runner));
    }
    return runners;
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) ArrayList(java.util.ArrayList) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) QueryRunner(org.apache.druid.query.QueryRunner)

Example 52 with QueryRunner

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

the class MaterializedViewQueryQueryToolChest method preMergeQueryDecoration.

@Override
public QueryRunner preMergeQueryDecoration(final QueryRunner runner) {
    return new QueryRunner() {

        @Override
        public Sequence run(QueryPlus queryPlus, ResponseContext responseContext) {
            Query realQuery = getRealQuery(queryPlus.getQuery());
            QueryToolChest realQueryToolChest = warehouse.getToolChest(realQuery);
            QueryRunner realQueryRunner = realQueryToolChest.preMergeQueryDecoration(new MaterializedViewQueryRunner(runner, optimizer));
            return realQueryRunner.run(queryPlus.withQuery(realQuery), responseContext);
        }
    };
}
Also used : Query(org.apache.druid.query.Query) ResponseContext(org.apache.druid.query.context.ResponseContext) QueryToolChest(org.apache.druid.query.QueryToolChest) QueryRunner(org.apache.druid.query.QueryRunner) QueryPlus(org.apache.druid.query.QueryPlus)

Example 53 with QueryRunner

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

the class TopNBenchmark method queryMultiQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole, QueryableIndexState state) {
    List<QueryRunner<Result<TopNResultValue>>> singleSegmentRunners = new ArrayList<>();
    QueryToolChest toolChest = factory.getToolchest();
    for (int i = 0; i < state.numSegments; i++) {
        SegmentId segmentId = SegmentId.dummy("qIndex " + i);
        QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, segmentId, new QueryableIndexSegment(state.qIndexes.get(i), segmentId));
        singleSegmentRunners.add(toolChest.preMergeQueryDecoration(runner));
    }
    QueryRunner theRunner = toolChest.postMergeQueryDecoration(new FinalizeResultsQueryRunner<>(toolChest.mergeResults(factory.mergeRunners(state.executorService, singleSegmentRunners)), toolChest));
    Sequence<Result<TopNResultValue>> queryResult = theRunner.run(QueryPlus.wrap(query), ResponseContext.createEmpty());
    List<Result<TopNResultValue>> results = queryResult.toList();
    blackhole.consume(results);
}
Also used : TopNResultValue(org.apache.druid.query.topn.TopNResultValue) QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) SegmentId(org.apache.druid.timeline.SegmentId) ArrayList(java.util.ArrayList) TopNQueryQueryToolChest(org.apache.druid.query.topn.TopNQueryQueryToolChest) QueryToolChest(org.apache.druid.query.QueryToolChest) QueryRunner(org.apache.druid.query.QueryRunner) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) 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 54 with QueryRunner

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

the class ScanBenchmark method queryMultiQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole, QueryableIndexState state) {
    List<SegmentDescriptor> segmentDescriptors = new ArrayList<>();
    List<QueryRunner<Row>> runners = new ArrayList<>();
    QueryToolChest toolChest = factory.getToolchest();
    for (int i = 0; i < state.numSegments; i++) {
        String segmentName = "qIndex";
        final QueryRunner<Result<ScanResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, SegmentId.dummy(segmentName), new QueryableIndexSegment(state.qIndexes.get(i), SegmentId.dummy(segmentName, i)));
        segmentDescriptors.add(new SegmentDescriptor(Intervals.ETERNITY, "dummy_version", i));
        runners.add(toolChest.preMergeQueryDecoration(runner));
    }
    QueryRunner theRunner = toolChest.postMergeQueryDecoration(new FinalizeResultsQueryRunner<>(toolChest.mergeResults(factory.mergeRunners(state.executorService, runners)), toolChest));
    Query effectiveQuery = query.withDataSource(new TableDataSource("qIndex")).withQuerySegmentSpec(new MultipleSpecificSegmentSpec(segmentDescriptors)).withOverriddenContext(ImmutableMap.of(ScanQuery.CTX_KEY_OUTERMOST, false));
    Sequence<Result<ScanResultValue>> queryResult = theRunner.run(QueryPlus.wrap(effectiveQuery), ResponseContext.createEmpty());
    List<Result<ScanResultValue>> results = queryResult.toList();
    blackhole.consume(results);
}
Also used : QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) MultipleSpecificSegmentSpec(org.apache.druid.query.spec.MultipleSpecificSegmentSpec) ScanQuery(org.apache.druid.query.scan.ScanQuery) Query(org.apache.druid.query.Query) ArrayList(java.util.ArrayList) ScanQueryQueryToolChest(org.apache.druid.query.scan.ScanQueryQueryToolChest) QueryToolChest(org.apache.druid.query.QueryToolChest) QueryRunner(org.apache.druid.query.QueryRunner) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) Result(org.apache.druid.query.Result) TableDataSource(org.apache.druid.query.TableDataSource) SegmentDescriptor(org.apache.druid.query.SegmentDescriptor) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 55 with QueryRunner

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

the class TimeseriesBenchmark method queryMultiQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole, QueryableIndexState state) {
    List<QueryRunner<Result<TimeseriesResultValue>>> singleSegmentRunners = new ArrayList<>();
    QueryToolChest toolChest = factory.getToolchest();
    for (int i = 0; i < state.numSegments; i++) {
        SegmentId segmentId = SegmentId.dummy("qIndex " + i);
        QueryRunner<Result<TimeseriesResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, segmentId, new QueryableIndexSegment(state.qIndexes.get(i), segmentId));
        singleSegmentRunners.add(toolChest.preMergeQueryDecoration(runner));
    }
    QueryRunner theRunner = toolChest.postMergeQueryDecoration(new FinalizeResultsQueryRunner<>(toolChest.mergeResults(factory.mergeRunners(state.executorService, singleSegmentRunners)), toolChest));
    Sequence<Result<TimeseriesResultValue>> queryResult = theRunner.run(QueryPlus.wrap(query), ResponseContext.createEmpty());
    List<Result<TimeseriesResultValue>> results = queryResult.toList();
    blackhole.consume(results);
}
Also used : QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) TimeseriesResultValue(org.apache.druid.query.timeseries.TimeseriesResultValue) SegmentId(org.apache.druid.timeline.SegmentId) ArrayList(java.util.ArrayList) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) QueryToolChest(org.apache.druid.query.QueryToolChest) QueryRunner(org.apache.druid.query.QueryRunner) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) 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

QueryRunner (org.apache.druid.query.QueryRunner)106 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)76 Test (org.junit.Test)69 ResponseContext (org.apache.druid.query.context.ResponseContext)38 QueryPlus (org.apache.druid.query.QueryPlus)36 ArrayList (java.util.ArrayList)34 Result (org.apache.druid.query.Result)33 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)30 QueryToolChest (org.apache.druid.query.QueryToolChest)28 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)28 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)25 Sequence (org.apache.druid.java.util.common.guava.Sequence)24 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)23 TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)22 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)20 Query (org.apache.druid.query.Query)18 TimeseriesResultValue (org.apache.druid.query.timeseries.TimeseriesResultValue)17 BySegmentQueryRunner (org.apache.druid.query.BySegmentQueryRunner)16 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)16 QueryableIndexSegment (org.apache.druid.segment.QueryableIndexSegment)16