use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class PredicateTreeAnalyzerTest method require_that_minfeature_is_min_for_or.
@Test
public void require_that_minfeature_is_min_for_or() {
Predicate p = or(and(feature("foo").inSet("bar"), feature("baz").inSet("qux"), feature("quux").inSet("corge")), and(feature("grault").inSet("garply"), feature("waldo").inSet("fred")));
PredicateTreeAnalyzerResult r = PredicateTreeAnalyzer.analyzePredicateTree(p);
assertEquals(2, r.minFeature);
assertEquals(5, r.treeSize);
assertEquals(5, r.sizeMap.size());
assertSizeMapContains(r, pred(p).child(0).child(0), 1);
assertSizeMapContains(r, pred(p).child(0).child(1), 1);
assertSizeMapContains(r, pred(p).child(0).child(2), 1);
assertSizeMapContains(r, pred(p).child(1).child(0), 1);
assertSizeMapContains(r, pred(p).child(1).child(1), 1);
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class PredicateTreeAnalyzerTest method require_that_minfeature_is_1_for_simple_negative_term.
@Test
public void require_that_minfeature_is_1_for_simple_negative_term() {
Predicate p = not(feature("foo").inSet("bar"));
PredicateTreeAnalyzerResult r = PredicateTreeAnalyzer.analyzePredicateTree(p);
assertEquals(1, r.minFeature);
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class PredicateTreeAnalyzerTest method require_that_not_ranges_dont_count_towards_minfeature_calculation.
@Test
public void require_that_not_ranges_dont_count_towards_minfeature_calculation() {
Predicate p = and(feature("foo").inRange(0, 10), not(feature("foo").inRange(0, 10)), feature("bar").inRange(0, 10), not(feature("bar").inRange(0, 10)));
PredicateTreeAnalyzerResult r = PredicateTreeAnalyzer.analyzePredicateTree(p);
assertEquals(3, r.minFeature);
assertEquals(6, r.treeSize);
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class PredicateTreeAnalyzerTest method require_that_minfeature_is_sum_for_and.
@Test
public void require_that_minfeature_is_sum_for_and() {
Predicate p = and(feature("foo").inSet("bar"), feature("baz").inSet("qux"), feature("quux").inSet("corge"));
PredicateTreeAnalyzerResult r = PredicateTreeAnalyzer.analyzePredicateTree(p);
assertEquals(3, r.minFeature);
assertEquals(3, r.treeSize);
assertEquals(3, r.sizeMap.size());
assertSizeMapContains(r, pred(p).child(0), 1);
assertSizeMapContains(r, pred(p).child(1), 1);
assertSizeMapContains(r, pred(p).child(2), 1);
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class PredicateTreeAnalyzerTest method require_that_not_features_dont_count_towards_minfeature_calculation.
@Test
public void require_that_not_features_dont_count_towards_minfeature_calculation() {
Predicate p = and(feature("foo").inSet("A"), not(feature("foo").inSet("A")), not(feature("foo").inSet("B")), feature("foo").inSet("B"));
PredicateTreeAnalyzerResult r = PredicateTreeAnalyzer.analyzePredicateTree(p);
assertEquals(3, r.minFeature);
assertEquals(6, r.treeSize);
}
Aggregations