use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class PredicateValueMatcherFactoryTest method testFloatProcessorNotMatchingValue.
@Test
public void testFloatProcessorNotMatchingValue() {
final TestColumnValueSelector<Float> columnValueSelector = TestColumnValueSelector.of(Float.class, ImmutableList.of(2.f), DateTimes.nowUtc());
columnValueSelector.advance();
final ValueMatcher matcher = forSelector("5.f").makeFloatProcessor(columnValueSelector);
Assert.assertFalse(matcher.matches());
}
use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class PredicateValueMatcherFactoryTest method testComplexProcessorNotMatchingLong.
@Test
public void testComplexProcessorNotMatchingLong() {
final TestColumnValueSelector<Long> columnValueSelector = TestColumnValueSelector.of(Long.class, ImmutableList.of(15L), DateTimes.nowUtc());
columnValueSelector.advance();
final ValueMatcher matcher = forSelector("11").makeComplexProcessor(columnValueSelector);
Assert.assertFalse(matcher.matches());
}
use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class PredicateValueMatcherFactoryTest method testFloatProcessorMatchingValue.
@Test
public void testFloatProcessorMatchingValue() {
final TestColumnValueSelector<Float> columnValueSelector = TestColumnValueSelector.of(Float.class, ImmutableList.of(2.f), DateTimes.nowUtc());
columnValueSelector.advance();
final ValueMatcher matcher = forSelector("2.f").makeFloatProcessor(columnValueSelector);
Assert.assertTrue(matcher.matches());
}
use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class ExpressionVirtualColumnTest method testMultiObjectSelectorMakesRightSelector.
@Test
public void testMultiObjectSelectorMakesRightSelector() {
DimensionSpec spec = new DefaultDimensionSpec("expr", "expr");
// do some ugly faking to test if SingleStringInputDeferredEvaluationExpressionDimensionSelector is created for multi-value expressions when possible
ColumnSelectorFactory factory = new ColumnSelectorFactory() {
@Override
public DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec) {
DimensionSelector delegate = COLUMN_SELECTOR_FACTORY.makeDimensionSelector(dimensionSpec);
DimensionSelector faker = new DimensionSelector() {
@Override
public IndexedInts getRow() {
return delegate.getRow();
}
@Override
public ValueMatcher makeValueMatcher(@Nullable String value) {
return delegate.makeValueMatcher(value);
}
@Override
public ValueMatcher makeValueMatcher(Predicate<String> predicate) {
return delegate.makeValueMatcher(predicate);
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
delegate.inspectRuntimeShape(inspector);
}
@Nullable
@Override
public Object getObject() {
return delegate.getObject();
}
@Override
public Class<?> classOfObject() {
return delegate.classOfObject();
}
@Override
public int getValueCardinality() {
// value doesn't matter as long as not CARDINALITY_UNKNOWN
return 3;
}
@Nullable
@Override
public String lookupName(int id) {
return null;
}
@Override
public boolean nameLookupPossibleInAdvance() {
// fake this so when SingleStringInputDeferredEvaluationExpressionDimensionSelector it doesn't explode
return true;
}
@Nullable
@Override
public IdLookup idLookup() {
return name -> 0;
}
};
return faker;
}
@Override
public ColumnValueSelector makeColumnValueSelector(String columnName) {
return COLUMN_SELECTOR_FACTORY.makeColumnValueSelector(columnName);
}
@Nullable
@Override
public ColumnCapabilities getColumnCapabilities(String column) {
return new ColumnCapabilitiesImpl().setType(ColumnType.STRING).setHasMultipleValues(true).setDictionaryEncoded(true);
}
};
final BaseObjectColumnValueSelector selectorImplicit = SCALE_LIST_SELF_IMPLICIT.makeDimensionSelector(spec, factory);
final BaseObjectColumnValueSelector selectorExplicit = SCALE_LIST_SELF_EXPLICIT.makeDimensionSelector(spec, factory);
Assert.assertTrue(selectorImplicit instanceof SingleStringInputDeferredEvaluationExpressionDimensionSelector);
Assert.assertTrue(selectorExplicit instanceof ExpressionMultiValueDimensionSelector);
}
use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class ExpressionVirtualColumnTest method testNullDimensionSelector.
@Test
public void testNullDimensionSelector() {
final DimensionSelector selector = X_PLUS_Y.makeDimensionSelector(new DefaultDimensionSpec("expr", "expr"), COLUMN_SELECTOR_FACTORY);
final ValueMatcher nonNullMatcher = selector.makeValueMatcher(Predicates.notNull());
CURRENT_ROW.set(ROW0);
Assert.assertEquals(false, nonNullMatcher.matches());
}
Aggregations