Search in sources :

Example 66 with ResultRow

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

the class GroupByBenchmark method queryMultiQueryableIndexWithSpillingTTFR.

/**
 * Measure the time to produce the first ResultRow unlike {@link #queryMultiQueryableIndexWithSpilling} measures
 * total query processing time. This measure is useful since the Broker can start merging as soon as the first
 * result is returned.
 */
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndexWithSpillingTTFR(Blackhole blackhole, QueryableIndexState state) throws IOException {
    QueryToolChest<ResultRow, GroupByQuery> toolChest = factory.getToolchest();
    QueryRunner<ResultRow> theRunner = new FinalizeResultsQueryRunner<>(toolChest.mergeResults(factory.mergeRunners(state.executorService, makeMultiRunners(state))), (QueryToolChest) toolChest);
    final GroupByQuery spillingQuery = query.withOverriddenContext(ImmutableMap.of("bufferGrouperMaxSize", 4000));
    Sequence<ResultRow> queryResult = theRunner.run(QueryPlus.wrap(spillingQuery), ResponseContext.createEmpty());
    Yielder<ResultRow> yielder = Yielders.each(queryResult);
    yielder.close();
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) GroupByQuery(org.apache.druid.query.groupby.GroupByQuery) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 67 with ResultRow

use of org.apache.druid.query.groupby.ResultRow 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 68 with ResultRow

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

the class SqlVsNativeBenchmark method queryNative.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void queryNative(Blackhole blackhole) {
    final Sequence<ResultRow> resultSequence = QueryPlus.wrap(groupByQuery).run(walker, ResponseContext.createEmpty());
    final ResultRow lastRow = resultSequence.accumulate(null, (accumulated, in) -> in);
    blackhole.consume(lastRow);
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 69 with ResultRow

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

the class GroupByTypeInterfaceBenchmark method querySingleQueryableIndexStringOnly.

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

Example 70 with ResultRow

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

the class GroupByTypeInterfaceBenchmark method querySingleQueryableIndexStringThenNumeric.

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

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