use of org.apache.druid.segment.DimensionSelector in project druid by druid-io.
the class SettableDimensionValueSelector method setValueFrom.
@Override
public void setValueFrom(ColumnValueSelector<?> selector) {
DimensionSelector dimensionSelector = (DimensionSelector) selector;
keptSelector = dimensionSelector;
IndexedInts row = dimensionSelector.getRow();
int rowSize = row.size();
keptRow.ensureSize(rowSize);
for (int i = 0; i < rowSize; i++) {
keptRow.setValue(i, row.get(i));
}
keptRow.setSize(rowSize);
}
use of org.apache.druid.segment.DimensionSelector in project druid by druid-io.
the class ListFilteredDimensionSpecDimensionSelectorTest method testAllowList.
private void testAllowList(boolean unknownCardinality, boolean validIdLookup, boolean nameLookupPossibleInAdvance, Class<? extends DimensionSelector> expectedDimensionSelectorClass) {
RowSupplier rowSupplier = new RowSupplier();
NonnullPair<Object2IntMap<String>, Int2ObjectMap<String>> dictionaries = createDictionaries(data);
DimensionSelector selector = targetWithAllowList.decorate(new StringDimensionSelectorForTest(rowSupplier, dictionaries.lhs, dictionaries.rhs, unknownCardinality, validIdLookup, nameLookupPossibleInAdvance));
Assert.assertSame(expectedDimensionSelectorClass, selector.getClass());
assertAllowListFiltering(rowSupplier, selector);
}
use of org.apache.druid.segment.DimensionSelector in project druid by druid-io.
the class ListFilteredDimensionSpecDimensionSelectorTest method testDenyList.
private void testDenyList(boolean unknownCardinality, boolean validIdLookup, boolean nameLookupPossibleInAdvance, Class<? extends DimensionSelector> expectedDimensionSelectorClass) {
RowSupplier rowSupplier = new RowSupplier();
NonnullPair<Object2IntMap<String>, Int2ObjectMap<String>> dictionaries = createDictionaries(data);
DimensionSelector selector = targetWithDenyList.decorate(new StringDimensionSelectorForTest(rowSupplier, dictionaries.lhs, dictionaries.rhs, unknownCardinality, validIdLookup, nameLookupPossibleInAdvance));
Assert.assertSame(expectedDimensionSelectorClass, selector.getClass());
assertDenyListFiltering(rowSupplier, selector);
}
use of org.apache.druid.segment.DimensionSelector in project druid by druid-io.
the class PrefixFilteredDimensionSpecTest method testDecorator.
@Test
public void testDecorator() {
PrefixFilteredDimensionSpec spec = new PrefixFilteredDimensionSpec(new DefaultDimensionSpec("foo", "far"), "c");
DimensionSelector selector = spec.decorate(TestDimensionSelector.INSTANCE);
Assert.assertEquals(1, selector.getValueCardinality());
IndexedInts row = selector.getRow();
Assert.assertEquals(1, row.size());
Assert.assertEquals(0, row.get(0));
Assert.assertEquals("c", selector.lookupName(0));
Assert.assertEquals(0, selector.idLookup().lookupId("c"));
}
use of org.apache.druid.segment.DimensionSelector in project druid by druid-io.
the class ListFilteredDimensionSpecTest method testDecoratorWithWhitelist.
@Test
public void testDecoratorWithWhitelist() {
ListFilteredDimensionSpec spec = new ListFilteredDimensionSpec(new DefaultDimensionSpec("foo", "bar"), ImmutableSet.of("c", "g"), true);
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"));
}
Aggregations