use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.
the class ExpressionAggregationBenchmark method compute.
private double compute(final Function<ColumnSelectorFactory, BufferAggregator> aggregatorFactory) {
final QueryableIndexStorageAdapter adapter = new QueryableIndexStorageAdapter(index);
final Sequence<Cursor> cursors = adapter.makeCursors(null, index.getDataInterval(), VirtualColumns.EMPTY, Granularities.ALL, false, null);
final List<Double> results = cursors.map(cursor -> {
final BufferAggregator bufferAggregator = aggregatorFactory.apply(cursor.getColumnSelectorFactory());
bufferAggregator.init(aggregationBuffer, 0);
while (!cursor.isDone()) {
bufferAggregator.aggregate(aggregationBuffer, 0);
cursor.advance();
}
final Double dbl = (Double) bufferAggregator.get(aggregationBuffer, 0);
bufferAggregator.close();
return dbl;
}).toList();
return Iterables.getOnlyElement(results);
}
use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.
the class ExpressionSelectorBenchmark method timeFloorUsingExtractionFn.
@Benchmark
public void timeFloorUsingExtractionFn(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.EMPTY, Granularities.ALL, false, null);
final List<?> results = cursors.map(cursor -> {
final DimensionSelector selector = cursor.getColumnSelectorFactory().makeDimensionSelector(new ExtractionDimensionSpec(ColumnHolder.TIME_COLUMN_NAME, "v", new TimeFormatExtractionFn(null, null, null, Granularities.HOUR, true)));
consumeDimension(cursor, selector, blackhole);
return null;
}).toList();
blackhole.consume(results);
}
use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.
the class ExpressionSelectorBenchmark method strlenUsingExpressionAsLong.
@Benchmark
public void strlenUsingExpressionAsLong(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("v", "strlen(s)", ColumnType.STRING, 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);
}
use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.
the class ExpressionSelectorBenchmark method stringConcatAndCompareOnLong.
@Benchmark
public void stringConcatAndCompareOnLong(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("v", "concat(n, ' is my favorite number') == '3 is my favorite number'", 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);
}
use of org.apache.druid.java.util.common.guava.Sequence in project druid by druid-io.
the class ExpressionSelectorBenchmark method strlenUsingExtractionFn.
@Benchmark
public void strlenUsingExtractionFn(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.EMPTY, Granularities.ALL, false, null);
final List<?> results = cursors.map(cursor -> {
final DimensionSelector selector = cursor.getColumnSelectorFactory().makeDimensionSelector(new ExtractionDimensionSpec("x", "v", StrlenExtractionFn.instance()));
consumeDimension(cursor, selector, blackhole);
return null;
}).toList();
blackhole.consume(results);
}
Aggregations