Search in sources :

Example 6 with IndexedInts

use of io.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(io.druid.segment.data.IndexedInts)

Example 7 with IndexedInts

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

the class StringGroupByColumnSelectorStrategy method initGroupingKeyColumnValue.

@Override
public void initGroupingKeyColumnValue(int keyBufferPosition, int columnIndex, Object rowObj, ByteBuffer keyBuffer, int[] stack) {
    IndexedInts row = (IndexedInts) rowObj;
    int rowSize = row.size();
    initializeGroupingKeyV2Dimension(row, rowSize, keyBuffer, keyBufferPosition);
    stack[columnIndex] = rowSize == 0 ? 0 : 1;
}
Also used : IndexedInts(io.druid.segment.data.IndexedInts)

Example 8 with IndexedInts

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

the class ForwardingFilteredDimensionSelector method getRow.

@Override
public IndexedInts getRow() {
    IndexedInts baseRow = selector.getRow();
    int baseRowSize = baseRow.size();
    int[] result = new int[baseRowSize];
    int resultSize = 0;
    for (int i = 0; i < baseRowSize; i++) {
        int forwardedValue = forwardMapping.get(baseRow.get(i));
        if (forwardedValue >= 0) {
            result[resultSize++] = forwardedValue;
        }
    }
    return ArrayBasedIndexedInts.of(result, resultSize);
}
Also used : ArrayBasedIndexedInts(io.druid.segment.data.ArrayBasedIndexedInts) IndexedInts(io.druid.segment.data.IndexedInts)

Example 9 with IndexedInts

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

the class ForwardingFilteredDimensionSelector method makeValueMatcher.

@Override
public ValueMatcher makeValueMatcher(Predicate<String> predicate) {
    final BitSet valueIds = DimensionSelectorUtils.makePredicateMatchingSet(this, predicate);
    final boolean matchNull = predicate.apply(null);
    return new ValueMatcher() {

        @Override
        public boolean matches() {
            final IndexedInts baseRow = selector.getRow();
            final int baseRowSize = baseRow.size();
            boolean nullRow = true;
            for (int i = 0; i < baseRowSize; ++i) {
                int forwardedValue = forwardMapping.get(baseRow.get(i));
                if (forwardedValue >= 0) {
                    if (valueIds.get(forwardedValue)) {
                        return true;
                    }
                    nullRow = false;
                }
            }
            // null should match empty rows in multi-value columns
            return nullRow && matchNull;
        }
    };
}
Also used : BooleanValueMatcher(io.druid.segment.filter.BooleanValueMatcher) ValueMatcher(io.druid.query.filter.ValueMatcher) ArrayBasedIndexedInts(io.druid.segment.data.ArrayBasedIndexedInts) IndexedInts(io.druid.segment.data.IndexedInts) BitSet(java.util.BitSet)

Example 10 with IndexedInts

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

the class PredicateFilteredDimensionSelector method makeValueMatcher.

@Override
public ValueMatcher makeValueMatcher(final Predicate<String> matcherPredicate) {
    final boolean matchNull = predicate.apply(null);
    return new ValueMatcher() {

        @Override
        public boolean matches() {
            final IndexedInts baseRow = selector.getRow();
            final int baseRowSize = baseRow.size();
            boolean nullRow = true;
            for (int i = 0; i < baseRowSize; ++i) {
                String rowValue = lookupName(baseRow.get(i));
                if (predicate.apply(rowValue)) {
                    if (matcherPredicate.apply(rowValue)) {
                        return true;
                    }
                    nullRow = false;
                }
            }
            // null should match empty rows in multi-value columns
            return nullRow && matchNull;
        }
    };
}
Also used : ValueMatcher(io.druid.query.filter.ValueMatcher) ArrayBasedIndexedInts(io.druid.segment.data.ArrayBasedIndexedInts) IndexedInts(io.druid.segment.data.IndexedInts)

Aggregations

IndexedInts (io.druid.segment.data.IndexedInts)41 DimensionSelector (io.druid.segment.DimensionSelector)14 ValueMatcher (io.druid.query.filter.ValueMatcher)9 ArrayBasedIndexedInts (io.druid.segment.data.ArrayBasedIndexedInts)8 Test (org.junit.Test)8 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)6 Cursor (io.druid.segment.Cursor)6 BooleanValueMatcher (io.druid.segment.filter.BooleanValueMatcher)6 ArrayList (java.util.ArrayList)5 ByteBuffer (java.nio.ByteBuffer)3 BitSet (java.util.BitSet)3 Function (com.google.common.base.Function)2 ImmutableList (com.google.common.collect.ImmutableList)2 IAE (io.druid.java.util.common.IAE)2 Aggregator (io.druid.query.aggregation.Aggregator)2 DimFilter (io.druid.query.filter.DimFilter)2 ColumnSelectorFactory (io.druid.segment.ColumnSelectorFactory)2 IdLookup (io.druid.segment.IdLookup)2 CompressedVSizeIntsIndexedSupplier (io.druid.segment.data.CompressedVSizeIntsIndexedSupplier)2 IncrementalIndexTest (io.druid.segment.data.IncrementalIndexTest)2