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"));
}
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"));
}
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)));
}
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());
}
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));
}
Aggregations