use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class OptimizePredicateTestCase method requireThatPredicateOptionsAreSet.
@Test
public void requireThatPredicateOptionsAreSet() {
final Predicate predicate = Mockito.mock(Predicate.class);
final PredicateFieldValue input = new PredicateFieldValue(predicate);
ExecutionContext ctx = new ExecutionContext().setValue(input).setVariable("arity", new IntegerFieldValue(10));
new OptimizePredicateExpression((predicate1, options) -> {
assertEquals(10, options.getArity());
assertEquals(0x8000000000000000L, options.getLowerBound());
assertEquals(0x7fffffffffffffffL, options.getUpperBound());
return predicate1;
}).execute(ctx);
ctx.setVariable("upper_bound", new LongFieldValue(1000));
ctx.setVariable("lower_bound", new LongFieldValue(0));
new OptimizePredicateExpression((value, options) -> {
assertEquals(10, options.getArity());
assertEquals(0, options.getLowerBound());
assertEquals(1000, options.getUpperBound());
return value;
}).execute(ctx);
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class AndOrSimplifierTest method assertSimplified.
private static void assertSimplified(Predicate expected, Predicate input) {
AndOrSimplifier simplifier = new AndOrSimplifier();
Predicate actual = simplifier.process(input, new PredicateOptions(10));
assertEquals(expected, actual);
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class ComplexNodeTransformerTest method requireThatExistingPartitionsAreCleared.
@Test
public void requireThatExistingPartitionsAreCleared() {
testConvert("foo in [10..19]", "foo in [10..19 (foo=10-19)]");
Predicate p = Predicate.fromString("foo in [10..19]");
((FeatureRange) p).addPartition(new RangePartition("foo", 10000L, 20000L, false));
ComplexNodeTransformer tranformer = new ComplexNodeTransformer();
Predicate converted = tranformer.process(p, new PredicateOptions(10, lowerBound, upperBound));
assertEquals("foo in [10..19 (foo=10-19)]", converted.toString());
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class OrSimplifierTest method require_that_or_with_feature_sets_of_different_keys_is_simplified.
@Test
public void require_that_or_with_feature_sets_of_different_keys_is_simplified() {
Predicate p = or(feature("key1").inSet("value1", "value3"), feature("key1").inSet("value2"), feature("key2").inSet("value1"), feature("key2").inSet("value2", "value3"));
Predicate expected = or(feature("key1").inSet("value1", "value2", "value3"), feature("key2").inSet("value1", "value2", "value3"));
assertConvertedPredicateEquals(expected, p);
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class OrSimplifierTest method require_that_or_below_not_is_converted.
@Test
public void require_that_or_below_not_is_converted() {
Predicate p = not(or(feature("key1").inSet("value1"), feature("key1").inSet("value2")));
Predicate expected = not(feature("key1").inSet("value1", "value2"));
assertConvertedPredicateEquals(expected, p);
}
Aggregations