Search in sources :

Example 56 with Sequence

use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.

the class ExpressionFilterBenchmark method expressionFilter.

@Benchmark
public void expressionFilter(Blackhole blackhole) {
    final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(expressionFilter.toFilter(), index.getDataInterval(), VirtualColumns.EMPTY, Granularities.ALL, false, null);
    final List<?> results = cursors.map(cursor -> {
        final ColumnValueSelector selector = cursor.getColumnSelectorFactory().makeColumnValueSelector("x");
        consumeString(cursor, selector, blackhole);
        return null;
    }).toList();
    blackhole.consume(results);
}
Also used : BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Arrays(java.util.Arrays) Measurement(org.openjdk.jmh.annotations.Measurement) Intervals(org.apache.druid.java.util.common.Intervals) SegmentGenerator(org.apache.druid.segment.generator.SegmentGenerator) Blackhole(org.openjdk.jmh.infra.Blackhole) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Scope(org.openjdk.jmh.annotations.Scope) Warmup(org.openjdk.jmh.annotations.Warmup) ImmutableList(com.google.common.collect.ImmutableList) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) TearDown(org.openjdk.jmh.annotations.TearDown) AndDimFilter(org.apache.druid.query.filter.AndDimFilter) Sequence(org.apache.druid.java.util.common.guava.Sequence) Setup(org.openjdk.jmh.annotations.Setup) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) VirtualColumns(org.apache.druid.segment.VirtualColumns) GeneratorColumnSchema(org.apache.druid.segment.generator.GeneratorColumnSchema) Mode(org.openjdk.jmh.annotations.Mode) Closer(org.apache.druid.java.util.common.io.Closer) Param(org.openjdk.jmh.annotations.Param) QueryableIndex(org.apache.druid.segment.QueryableIndex) GeneratorSchemaInfo(org.apache.druid.segment.generator.GeneratorSchemaInfo) ValueType(org.apache.druid.segment.column.ValueType) TestExprMacroTable(org.apache.druid.query.expression.TestExprMacroTable) State(org.openjdk.jmh.annotations.State) Benchmark(org.openjdk.jmh.annotations.Benchmark) Granularities(org.apache.druid.java.util.common.granularity.Granularities) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) DimFilter(org.apache.druid.query.filter.DimFilter) Cursor(org.apache.druid.segment.Cursor) NullHandling(org.apache.druid.common.config.NullHandling) LinearShardSpec(org.apache.druid.timeline.partition.LinearShardSpec) DataSegment(org.apache.druid.timeline.DataSegment) Level(org.openjdk.jmh.annotations.Level) Fork(org.openjdk.jmh.annotations.Fork) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) Cursor(org.apache.druid.segment.Cursor) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 57 with Sequence

use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.

the class ExpressionSelectorBenchmark method arithmeticOnLong.

@Benchmark
public void arithmeticOnLong(Blackhole blackhole) {
    final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("v", "n + 1", ColumnType.LONG, TestExprMacroTable.INSTANCE))), Granularities.ALL, false, null);
    final List<?> results = cursors.map(cursor -> {
        final ColumnValueSelector selector = cursor.getColumnSelectorFactory().makeColumnValueSelector("v");
        consumeLong(cursor, selector, blackhole);
        return null;
    }).toList();
    blackhole.consume(results);
}
Also used : BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Measurement(org.openjdk.jmh.annotations.Measurement) Intervals(org.apache.druid.java.util.common.Intervals) SegmentGenerator(org.apache.druid.segment.generator.SegmentGenerator) Blackhole(org.openjdk.jmh.infra.Blackhole) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Scope(org.openjdk.jmh.annotations.Scope) Warmup(org.openjdk.jmh.annotations.Warmup) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) ColumnHolder(org.apache.druid.segment.column.ColumnHolder) ImmutableList(com.google.common.collect.ImmutableList) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) DimensionSelector(org.apache.druid.segment.DimensionSelector) TearDown(org.openjdk.jmh.annotations.TearDown) ExtractionDimensionSpec(org.apache.druid.query.dimension.ExtractionDimensionSpec) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) Sequence(org.apache.druid.java.util.common.guava.Sequence) Setup(org.openjdk.jmh.annotations.Setup) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) VirtualColumns(org.apache.druid.segment.VirtualColumns) GeneratorColumnSchema(org.apache.druid.segment.generator.GeneratorColumnSchema) Mode(org.openjdk.jmh.annotations.Mode) Closer(org.apache.druid.java.util.common.io.Closer) TimeFormatExtractionFn(org.apache.druid.query.extraction.TimeFormatExtractionFn) Param(org.openjdk.jmh.annotations.Param) QueryableIndex(org.apache.druid.segment.QueryableIndex) GeneratorSchemaInfo(org.apache.druid.segment.generator.GeneratorSchemaInfo) ValueType(org.apache.druid.segment.column.ValueType) TestExprMacroTable(org.apache.druid.query.expression.TestExprMacroTable) State(org.openjdk.jmh.annotations.State) StrlenExtractionFn(org.apache.druid.query.extraction.StrlenExtractionFn) Benchmark(org.openjdk.jmh.annotations.Benchmark) Granularities(org.apache.druid.java.util.common.granularity.Granularities) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Cursor(org.apache.druid.segment.Cursor) NullHandling(org.apache.druid.common.config.NullHandling) LinearShardSpec(org.apache.druid.timeline.partition.LinearShardSpec) DataSegment(org.apache.druid.timeline.DataSegment) Level(org.openjdk.jmh.annotations.Level) ColumnType(org.apache.druid.segment.column.ColumnType) Fork(org.openjdk.jmh.annotations.Fork) BitSet(java.util.BitSet) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) Cursor(org.apache.druid.segment.Cursor) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 58 with Sequence

use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.

the class ExpressionSelectorBenchmark method timeFloorUsingExpression.

@Benchmark
public void timeFloorUsingExpression(Blackhole blackhole) {
    final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("v", "timestamp_floor(__time, 'PT1H')", ColumnType.LONG, TestExprMacroTable.INSTANCE))), Granularities.ALL, false, null);
    final List<?> results = cursors.map(cursor -> {
        final ColumnValueSelector selector = cursor.getColumnSelectorFactory().makeColumnValueSelector("v");
        consumeLong(cursor, selector, blackhole);
        return null;
    }).toList();
    blackhole.consume(results);
}
Also used : BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Measurement(org.openjdk.jmh.annotations.Measurement) Intervals(org.apache.druid.java.util.common.Intervals) SegmentGenerator(org.apache.druid.segment.generator.SegmentGenerator) Blackhole(org.openjdk.jmh.infra.Blackhole) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Scope(org.openjdk.jmh.annotations.Scope) Warmup(org.openjdk.jmh.annotations.Warmup) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) ColumnHolder(org.apache.druid.segment.column.ColumnHolder) ImmutableList(com.google.common.collect.ImmutableList) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) DimensionSelector(org.apache.druid.segment.DimensionSelector) TearDown(org.openjdk.jmh.annotations.TearDown) ExtractionDimensionSpec(org.apache.druid.query.dimension.ExtractionDimensionSpec) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) Sequence(org.apache.druid.java.util.common.guava.Sequence) Setup(org.openjdk.jmh.annotations.Setup) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) VirtualColumns(org.apache.druid.segment.VirtualColumns) GeneratorColumnSchema(org.apache.druid.segment.generator.GeneratorColumnSchema) Mode(org.openjdk.jmh.annotations.Mode) Closer(org.apache.druid.java.util.common.io.Closer) TimeFormatExtractionFn(org.apache.druid.query.extraction.TimeFormatExtractionFn) Param(org.openjdk.jmh.annotations.Param) QueryableIndex(org.apache.druid.segment.QueryableIndex) GeneratorSchemaInfo(org.apache.druid.segment.generator.GeneratorSchemaInfo) ValueType(org.apache.druid.segment.column.ValueType) TestExprMacroTable(org.apache.druid.query.expression.TestExprMacroTable) State(org.openjdk.jmh.annotations.State) StrlenExtractionFn(org.apache.druid.query.extraction.StrlenExtractionFn) Benchmark(org.openjdk.jmh.annotations.Benchmark) Granularities(org.apache.druid.java.util.common.granularity.Granularities) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Cursor(org.apache.druid.segment.Cursor) NullHandling(org.apache.druid.common.config.NullHandling) LinearShardSpec(org.apache.druid.timeline.partition.LinearShardSpec) DataSegment(org.apache.druid.timeline.DataSegment) Level(org.openjdk.jmh.annotations.Level) ColumnType(org.apache.druid.segment.column.ColumnType) Fork(org.openjdk.jmh.annotations.Fork) BitSet(java.util.BitSet) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) Cursor(org.apache.druid.segment.Cursor) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 59 with Sequence

use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.

the class ExpressionSelectorBenchmark method timeFloorUsingCursor.

@Benchmark
public void timeFloorUsingCursor(Blackhole blackhole) {
    final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.EMPTY, Granularities.HOUR, false, null);
    final List<Long> results = cursors.map(cursor -> {
        long count = 0L;
        while (!cursor.isDone()) {
            count++;
            cursor.advance();
        }
        return count;
    }).toList();
    long count = 0L;
    for (Long result : results) {
        count += result;
    }
    blackhole.consume(count);
}
Also used : BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Measurement(org.openjdk.jmh.annotations.Measurement) Intervals(org.apache.druid.java.util.common.Intervals) SegmentGenerator(org.apache.druid.segment.generator.SegmentGenerator) Blackhole(org.openjdk.jmh.infra.Blackhole) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Scope(org.openjdk.jmh.annotations.Scope) Warmup(org.openjdk.jmh.annotations.Warmup) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) ColumnHolder(org.apache.druid.segment.column.ColumnHolder) ImmutableList(com.google.common.collect.ImmutableList) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) DimensionSelector(org.apache.druid.segment.DimensionSelector) TearDown(org.openjdk.jmh.annotations.TearDown) ExtractionDimensionSpec(org.apache.druid.query.dimension.ExtractionDimensionSpec) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) Sequence(org.apache.druid.java.util.common.guava.Sequence) Setup(org.openjdk.jmh.annotations.Setup) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) VirtualColumns(org.apache.druid.segment.VirtualColumns) GeneratorColumnSchema(org.apache.druid.segment.generator.GeneratorColumnSchema) Mode(org.openjdk.jmh.annotations.Mode) Closer(org.apache.druid.java.util.common.io.Closer) TimeFormatExtractionFn(org.apache.druid.query.extraction.TimeFormatExtractionFn) Param(org.openjdk.jmh.annotations.Param) QueryableIndex(org.apache.druid.segment.QueryableIndex) GeneratorSchemaInfo(org.apache.druid.segment.generator.GeneratorSchemaInfo) ValueType(org.apache.druid.segment.column.ValueType) TestExprMacroTable(org.apache.druid.query.expression.TestExprMacroTable) State(org.openjdk.jmh.annotations.State) StrlenExtractionFn(org.apache.druid.query.extraction.StrlenExtractionFn) Benchmark(org.openjdk.jmh.annotations.Benchmark) Granularities(org.apache.druid.java.util.common.granularity.Granularities) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Cursor(org.apache.druid.segment.Cursor) NullHandling(org.apache.druid.common.config.NullHandling) LinearShardSpec(org.apache.druid.timeline.partition.LinearShardSpec) DataSegment(org.apache.druid.timeline.DataSegment) Level(org.openjdk.jmh.annotations.Level) ColumnType(org.apache.druid.segment.column.ColumnType) Fork(org.openjdk.jmh.annotations.Fork) BitSet(java.util.BitSet) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) Cursor(org.apache.druid.segment.Cursor) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 60 with Sequence

use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.

the class ExpressionVectorSelectorBenchmark method scan.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void scan(Blackhole blackhole) {
    final VirtualColumns virtualColumns = VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("v", expression, ExpressionType.toColumnType(outputType), TestExprMacroTable.INSTANCE)));
    if (vectorize) {
        VectorCursor cursor = new QueryableIndexStorageAdapter(index).makeVectorCursor(null, index.getDataInterval(), virtualColumns, false, 512, null);
        if (outputType.isNumeric()) {
            VectorValueSelector selector = cursor.getColumnSelectorFactory().makeValueSelector("v");
            if (outputType.is(ExprType.DOUBLE)) {
                while (!cursor.isDone()) {
                    blackhole.consume(selector.getDoubleVector());
                    blackhole.consume(selector.getNullVector());
                    cursor.advance();
                }
            } else {
                while (!cursor.isDone()) {
                    blackhole.consume(selector.getLongVector());
                    blackhole.consume(selector.getNullVector());
                    cursor.advance();
                }
            }
            closer.register(cursor);
        }
    } else {
        Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), virtualColumns, Granularities.ALL, false, null);
        int rowCount = cursors.map(cursor -> {
            final ColumnValueSelector selector = cursor.getColumnSelectorFactory().makeColumnValueSelector("v");
            int rows = 0;
            while (!cursor.isDone()) {
                blackhole.consume(selector.getObject());
                rows++;
                cursor.advance();
            }
            return rows;
        }).accumulate(0, (acc, in) -> acc + in);
        blackhole.consume(rowCount);
    }
}
Also used : BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Measurement(org.openjdk.jmh.annotations.Measurement) SegmentGenerator(org.apache.druid.segment.generator.SegmentGenerator) Blackhole(org.openjdk.jmh.infra.Blackhole) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Parser(org.apache.druid.math.expr.Parser) Scope(org.openjdk.jmh.annotations.Scope) ExprType(org.apache.druid.math.expr.ExprType) Warmup(org.openjdk.jmh.annotations.Warmup) GeneratorBasicSchemas(org.apache.druid.segment.generator.GeneratorBasicSchemas) VectorCursor(org.apache.druid.segment.vector.VectorCursor) ImmutableList(com.google.common.collect.ImmutableList) ExpressionType(org.apache.druid.math.expr.ExpressionType) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) Expr(org.apache.druid.math.expr.Expr) TearDown(org.openjdk.jmh.annotations.TearDown) ExpressionVectorSelectorsTest(org.apache.druid.segment.virtual.ExpressionVectorSelectorsTest) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) Nullable(javax.annotation.Nullable) Sequence(org.apache.druid.java.util.common.guava.Sequence) ColumnInspector(org.apache.druid.segment.ColumnInspector) Setup(org.openjdk.jmh.annotations.Setup) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) VirtualColumns(org.apache.druid.segment.VirtualColumns) Mode(org.openjdk.jmh.annotations.Mode) Closer(org.apache.druid.java.util.common.io.Closer) Param(org.openjdk.jmh.annotations.Param) QueryableIndex(org.apache.druid.segment.QueryableIndex) GeneratorSchemaInfo(org.apache.druid.segment.generator.GeneratorSchemaInfo) TestExprMacroTable(org.apache.druid.query.expression.TestExprMacroTable) VectorValueSelector(org.apache.druid.segment.vector.VectorValueSelector) State(org.openjdk.jmh.annotations.State) Benchmark(org.openjdk.jmh.annotations.Benchmark) Granularities(org.apache.druid.java.util.common.granularity.Granularities) ExprMacroTable(org.apache.druid.math.expr.ExprMacroTable) TimeUnit(java.util.concurrent.TimeUnit) Cursor(org.apache.druid.segment.Cursor) NullHandling(org.apache.druid.common.config.NullHandling) LinearShardSpec(org.apache.druid.timeline.partition.LinearShardSpec) DataSegment(org.apache.druid.timeline.DataSegment) Level(org.openjdk.jmh.annotations.Level) ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) Fork(org.openjdk.jmh.annotations.Fork) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) VectorValueSelector(org.apache.druid.segment.vector.VectorValueSelector) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) VectorCursor(org.apache.druid.segment.vector.VectorCursor) Cursor(org.apache.druid.segment.Cursor) VectorCursor(org.apache.druid.segment.vector.VectorCursor) VirtualColumns(org.apache.druid.segment.VirtualColumns) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

Sequence (org.apache.druid.java.util.common.guava.Sequence)102 Test (org.junit.Test)53 List (java.util.List)44 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)37 ResponseContext (org.apache.druid.query.context.ResponseContext)32 ImmutableList (com.google.common.collect.ImmutableList)29 Intervals (org.apache.druid.java.util.common.Intervals)28 Granularities (org.apache.druid.java.util.common.granularity.Granularities)28 QueryRunner (org.apache.druid.query.QueryRunner)28 ArrayList (java.util.ArrayList)27 VirtualColumns (org.apache.druid.segment.VirtualColumns)26 Cursor (org.apache.druid.segment.Cursor)25 QueryPlus (org.apache.druid.query.QueryPlus)24 Result (org.apache.druid.query.Result)24 NullHandling (org.apache.druid.common.config.NullHandling)22 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)22 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)21 QueryableIndexStorageAdapter (org.apache.druid.segment.QueryableIndexStorageAdapter)20 DataSegment (org.apache.druid.timeline.DataSegment)20 ImmutableMap (com.google.common.collect.ImmutableMap)18