Search in sources :

Example 11 with IdLookup

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

the class CardinalityVectorAggregatorTest method testAggregateMultiValueString.

@Test
public void testAggregateMultiValueString() {
    final IndexedInts[] ids = { new ArrayBasedIndexedInts(new int[] { 1, 2 }), new ArrayBasedIndexedInts(new int[] { 2, 3 }), new ArrayBasedIndexedInts(new int[] { 3, 3 }), new ArrayBasedIndexedInts(new int[] { 0 }) };
    final String[] dict = { null, "abc", "def", "foo" };
    final CardinalityVectorAggregator aggregator = new CardinalityVectorAggregator(Collections.singletonList(new MultiValueStringCardinalityVectorProcessor(new MultiValueDimensionVectorSelector() {

        @Override
        public IndexedInts[] getRowVector() {
            return ids;
        }

        @Override
        public int getValueCardinality() {
            return dict.length;
        }

        @Nullable
        @Override
        public String lookupName(int id) {
            return dict[id];
        }

        @Override
        public boolean nameLookupPossibleInAdvance() {
            return true;
        }

        @Nullable
        @Override
        public IdLookup idLookup() {
            return null;
        }

        @Override
        public int getMaxVectorSize() {
            return ids.length;
        }

        @Override
        public int getCurrentVectorSize() {
            return ids.length;
        }
    })));
    testAggregate(aggregator, ids.length, NullHandling.replaceWithDefault() ? 4 : 3);
}
Also used : IdLookup(org.apache.druid.segment.IdLookup) MultiValueDimensionVectorSelector(org.apache.druid.segment.vector.MultiValueDimensionVectorSelector) ArrayBasedIndexedInts(org.apache.druid.segment.data.ArrayBasedIndexedInts) MultiValueStringCardinalityVectorProcessor(org.apache.druid.query.aggregation.cardinality.vector.MultiValueStringCardinalityVectorProcessor) IndexedInts(org.apache.druid.segment.data.IndexedInts) ArrayBasedIndexedInts(org.apache.druid.segment.data.ArrayBasedIndexedInts) Nullable(javax.annotation.Nullable) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

IdLookup (org.apache.druid.segment.IdLookup)11 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)6 Test (org.junit.Test)6 Nullable (javax.annotation.Nullable)5 ColumnCapabilitiesImpl (org.apache.druid.segment.column.ColumnCapabilitiesImpl)5 IndexedInts (org.apache.druid.segment.data.IndexedInts)5 ValueMatcher (org.apache.druid.query.filter.ValueMatcher)4 RuntimeShapeInspector (org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)4 SingleValueDimensionVectorSelector (org.apache.druid.segment.vector.SingleValueDimensionVectorSelector)3 Predicate (com.google.common.base.Predicate)2 DimensionSpec (org.apache.druid.query.dimension.DimensionSpec)2 AbstractDimensionSelector (org.apache.druid.segment.AbstractDimensionSelector)2 ColumnSelectorFactory (org.apache.druid.segment.ColumnSelectorFactory)2 SingleIndexedInt (org.apache.druid.segment.data.SingleIndexedInt)2 BooleanValueMatcher (org.apache.druid.segment.filter.BooleanValueMatcher)2 MultiValueDimensionVectorSelector (org.apache.druid.segment.vector.MultiValueDimensionVectorSelector)2 Predicates (com.google.common.base.Predicates)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Arrays (java.util.Arrays)1