Search in sources :

Example 51 with IndexedInts

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

the class ListFilteredDimensionSpecTest method testDecoratorWithBlacklistUsingNonPresentValues.

@Test
public void testDecoratorWithBlacklistUsingNonPresentValues() {
    ListFilteredDimensionSpec spec = new ListFilteredDimensionSpec(new DefaultDimensionSpec("foo", "bar"), ImmutableSet.of("c", "gx"), false);
    DimensionSelector selector = spec.decorate(TestDimensionSelector.INSTANCE);
    Assert.assertEquals(25, selector.getValueCardinality());
    IndexedInts row = selector.getRow();
    Assert.assertEquals(2, row.size());
    Assert.assertEquals(3, row.get(0));
    Assert.assertEquals(5, row.get(1));
    Assert.assertEquals("e", selector.lookupName(row.get(0)));
    Assert.assertEquals("g", selector.lookupName(row.get(1)));
    Assert.assertEquals("a", selector.lookupName(0));
    Assert.assertEquals("z", selector.lookupName(24));
    Assert.assertEquals(0, selector.idLookup().lookupId("a"));
    Assert.assertEquals(24, selector.idLookup().lookupId("z"));
}
Also used : DimensionSelector(org.apache.druid.segment.DimensionSelector) IndexedInts(org.apache.druid.segment.data.IndexedInts) Test(org.junit.Test)

Example 52 with IndexedInts

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

the class RegexFilteredDimensionSpecTest method testDecorator.

@Test
public void testDecorator() {
    RegexFilteredDimensionSpec spec = new RegexFilteredDimensionSpec(new DefaultDimensionSpec("foo", "bar"), "[c,g]");
    DimensionSelector selector = spec.decorate(TestDimensionSelector.INSTANCE);
    Assert.assertEquals(2, selector.getValueCardinality());
    IndexedInts row = selector.getRow();
    Assert.assertEquals(2, row.size());
    Assert.assertEquals(0, row.get(0));
    Assert.assertEquals(1, row.get(1));
    Assert.assertEquals("c", selector.lookupName(0));
    Assert.assertEquals("g", selector.lookupName(1));
    Assert.assertEquals(0, selector.idLookup().lookupId("c"));
    Assert.assertEquals(1, selector.idLookup().lookupId("g"));
}
Also used : DimensionSelector(org.apache.druid.segment.DimensionSelector) IndexedInts(org.apache.druid.segment.data.IndexedInts) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 53 with IndexedInts

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

the class ListFilteredDimensionSpecDimensionSelectorTest method assertDenyListFiltering.

private void assertDenyListFiltering(RowSupplier rowSupplier, DimensionSelector selector) {
    rowSupplier.set(data.get(0));
    IndexedInts encodedRow = selector.getRow();
    Assert.assertEquals(1, encodedRow.size());
    Assert.assertEquals("val1_2", selector.lookupName(encodedRow.get(0)));
    rowSupplier.set(data.get(1));
    encodedRow = selector.getRow();
    Assert.assertEquals(1, encodedRow.size());
    Assert.assertEquals("val2_1", selector.lookupName(encodedRow.get(0)));
    rowSupplier.set(data.get(2));
    encodedRow = selector.getRow();
    Assert.assertEquals(1, encodedRow.size());
    Assert.assertEquals("val3_1", selector.lookupName(encodedRow.get(0)));
}
Also used : IndexedInts(org.apache.druid.segment.data.IndexedInts)

Example 54 with IndexedInts

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

the class ListFilteredDimensionSpecDimensionSelectorTest method assertAllowListFiltering.

private void assertAllowListFiltering(RowSupplier rowSupplier, DimensionSelector selector) {
    rowSupplier.set(data.get(0));
    IndexedInts encodedRow = selector.getRow();
    Assert.assertEquals(1, encodedRow.size());
    Assert.assertEquals("val1_1", selector.lookupName(encodedRow.get(0)));
    rowSupplier.set(data.get(1));
    encodedRow = selector.getRow();
    Assert.assertEquals(2, encodedRow.size());
    Assert.assertEquals("val2_2", selector.lookupName(encodedRow.get(0)));
    Assert.assertEquals("val2_3", selector.lookupName(encodedRow.get(1)));
    rowSupplier.set(data.get(2));
    encodedRow = selector.getRow();
    Assert.assertEquals(0, encodedRow.size());
}
Also used : IndexedInts(org.apache.druid.segment.data.IndexedInts)

Example 55 with IndexedInts

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

the class ConstantMultiValueDimensionSelectorTest method testGetRow.

@Test
public void testGetRow() {
    IndexedInts row = NULL_SELECTOR.getRow();
    Assert.assertEquals(1, row.size());
    Assert.assertEquals(0, row.get(0));
    row = EMPTY_SELECTOR.getRow();
    Assert.assertEquals(1, row.size());
    Assert.assertEquals(0, row.get(0));
    row = SINGLE_SELECTOR.getRow();
    Assert.assertEquals(1, row.size());
    Assert.assertEquals(0, row.get(0));
    row = CONST_SELECTOR.getRow();
    Assert.assertEquals(2, row.size());
    Assert.assertEquals(0, row.get(0));
    Assert.assertEquals(1, row.get(1));
    row = NULL_EXTRACTION_SELECTOR.getRow();
    Assert.assertEquals(1, row.size());
    Assert.assertEquals(0, row.get(0));
    row = CONST_EXTRACTION_SELECTOR.getRow();
    Assert.assertEquals(3, row.size());
    Assert.assertEquals(0, row.get(0));
    Assert.assertEquals(1, row.get(1));
    Assert.assertEquals(2, row.get(2));
}
Also used : IndexedInts(org.apache.druid.segment.data.IndexedInts) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

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