Search in sources :

Example 31 with IndexedInts

use of org.apache.druid.segment.data.IndexedInts in project druid by druid-io.

the class IncrementalIndexReadBenchmark method readWithFilters.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void readWithFilters(Blackhole blackhole) {
    DimFilter filter = new OrDimFilter(Arrays.asList(new BoundDimFilter("dimSequential", "-1", "-1", true, true, null, null, StringComparators.ALPHANUMERIC), new JavaScriptDimFilter("dimSequential", "function(x) { return false }", null, JavaScriptConfig.getEnabledInstance()), new RegexDimFilter("dimSequential", "X", null), new SearchQueryDimFilter("dimSequential", new ContainsSearchQuerySpec("X", false), null), new InDimFilter("dimSequential", Collections.singletonList("X"), null)));
    IncrementalIndexStorageAdapter sa = new IncrementalIndexStorageAdapter(incIndex);
    Sequence<Cursor> cursors = makeCursors(sa, filter);
    Cursor cursor = cursors.limit(1).toList().get(0);
    List<DimensionSelector> selectors = new ArrayList<>();
    selectors.add(makeDimensionSelector(cursor, "dimSequential"));
    selectors.add(makeDimensionSelector(cursor, "dimZipf"));
    selectors.add(makeDimensionSelector(cursor, "dimUniform"));
    selectors.add(makeDimensionSelector(cursor, "dimSequentialHalfNull"));
    cursor.reset();
    while (!cursor.isDone()) {
        for (DimensionSelector selector : selectors) {
            IndexedInts row = selector.getRow();
            blackhole.consume(selector.lookupName(row.get(0)));
        }
        cursor.advance();
    }
}
Also used : RegexDimFilter(org.apache.druid.query.filter.RegexDimFilter) DimensionSelector(org.apache.druid.segment.DimensionSelector) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) ContainsSearchQuerySpec(org.apache.druid.query.search.ContainsSearchQuerySpec) ArrayList(java.util.ArrayList) Cursor(org.apache.druid.segment.Cursor) IndexedInts(org.apache.druid.segment.data.IndexedInts) OrDimFilter(org.apache.druid.query.filter.OrDimFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) IncrementalIndexStorageAdapter(org.apache.druid.segment.incremental.IncrementalIndexStorageAdapter) SearchQueryDimFilter(org.apache.druid.query.filter.SearchQueryDimFilter) JavaScriptDimFilter(org.apache.druid.query.filter.JavaScriptDimFilter) SearchQueryDimFilter(org.apache.druid.query.filter.SearchQueryDimFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) RegexDimFilter(org.apache.druid.query.filter.RegexDimFilter) DimFilter(org.apache.druid.query.filter.DimFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) OrDimFilter(org.apache.druid.query.filter.OrDimFilter) JavaScriptDimFilter(org.apache.druid.query.filter.JavaScriptDimFilter) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 32 with IndexedInts

use of org.apache.druid.segment.data.IndexedInts in project druid by druid-io.

the class DistinctCountBufferAggregator method aggregate.

@Override
public void aggregate(ByteBuffer buf, int position) {
    MutableBitmap mutableBitmap = getMutableBitmap(position);
    IndexedInts row = selector.getRow();
    for (int i = 0, rowSize = row.size(); i < rowSize; i++) {
        int index = row.get(i);
        mutableBitmap.add(index);
    }
    buf.putLong(position, mutableBitmap.size());
}
Also used : IndexedInts(org.apache.druid.segment.data.IndexedInts) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap)

Example 33 with IndexedInts

use of org.apache.druid.segment.data.IndexedInts in project druid by druid-io.

the class DistinctCountAggregator method aggregate.

@Override
public void aggregate() {
    IndexedInts row = selector.getRow();
    for (int i = 0, rowSize = row.size(); i < rowSize; i++) {
        int index = row.get(i);
        mutableBitmap.add(index);
    }
}
Also used : IndexedInts(org.apache.druid.segment.data.IndexedInts)

Example 34 with IndexedInts

use of org.apache.druid.segment.data.IndexedInts in project druid by druid-io.

the class StringGroupByColumnSelectorStrategy method getOnlyValue.

@Override
public Object getOnlyValue(ColumnValueSelector selector) {
    final DimensionSelector dimSelector = (DimensionSelector) selector;
    final IndexedInts row = dimSelector.getRow();
    Preconditions.checkState(row.size() < 2, "Not supported for multi-value dimensions");
    return row.size() == 1 ? row.get(0) : GROUP_BY_MISSING_VALUE;
}
Also used : DimensionSelector(org.apache.druid.segment.DimensionSelector) IndexedInts(org.apache.druid.segment.data.IndexedInts)

Example 35 with IndexedInts

use of org.apache.druid.segment.data.IndexedInts in project druid by druid-io.

the class StringGroupByColumnSelectorStrategy method checkRowIndexAndAddValueToGroupingKey.

@Override
public boolean checkRowIndexAndAddValueToGroupingKey(int keyBufferPosition, Object rowObj, int rowValIdx, ByteBuffer keyBuffer) {
    IndexedInts row = (IndexedInts) rowObj;
    int rowSize = row.size();
    if (rowValIdx < rowSize) {
        keyBuffer.putInt(keyBufferPosition, row.get(rowValIdx));
        return true;
    } else {
        return false;
    }
}
Also used : IndexedInts(org.apache.druid.segment.data.IndexedInts)

Aggregations

IndexedInts (org.apache.druid.segment.data.IndexedInts)63 DimensionSelector (org.apache.druid.segment.DimensionSelector)22 ValueMatcher (org.apache.druid.query.filter.ValueMatcher)14 Test (org.junit.Test)13 RuntimeShapeInspector (org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)12 ArrayBasedIndexedInts (org.apache.druid.segment.data.ArrayBasedIndexedInts)12 Cursor (org.apache.druid.segment.Cursor)10 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)8 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)7 Predicate (com.google.common.base.Predicate)6 ByteBuffer (java.nio.ByteBuffer)6 Nullable (javax.annotation.Nullable)6 ColumnSelectorFactory (org.apache.druid.segment.ColumnSelectorFactory)6 BooleanValueMatcher (org.apache.druid.segment.filter.BooleanValueMatcher)6 List (java.util.List)5 Predicates (com.google.common.base.Predicates)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 Arrays (java.util.Arrays)4 NullHandling (org.apache.druid.common.config.NullHandling)4 MapBasedInputRow (org.apache.druid.data.input.MapBasedInputRow)4