Search in sources :

Example 36 with Predicate

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);
}
Also used : Predicate(com.yahoo.document.predicate.Predicate) Test(org.junit.Test)

Example 37 with Predicate

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);
}
Also used : Predicate(com.yahoo.document.predicate.Predicate) Test(org.junit.Test)

Example 38 with Predicate

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);
}
Also used : Predicate(com.yahoo.document.predicate.Predicate) Test(org.junit.Test)

Example 39 with Predicate

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);
}
Also used : Predicate(com.yahoo.document.predicate.Predicate) Test(org.junit.Test)

Example 40 with Predicate

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);
}
Also used : Predicate(com.yahoo.document.predicate.Predicate) Test(org.junit.Test)

Aggregations

Predicate (com.yahoo.document.predicate.Predicate)45 Test (org.junit.Test)33 Conjunction (com.yahoo.document.predicate.Conjunction)7 Disjunction (com.yahoo.document.predicate.Disjunction)6 Negation (com.yahoo.document.predicate.Negation)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 FeatureConjunction (com.yahoo.document.predicate.FeatureConjunction)3 FeatureRange (com.yahoo.document.predicate.FeatureRange)3 FeatureSet (com.yahoo.document.predicate.FeatureSet)3 IndexableFeatureConjunction (com.yahoo.search.predicate.index.conjunction.IndexableFeatureConjunction)3 Map (java.util.Map)3 DataType (com.yahoo.document.DataType)2 FieldValue (com.yahoo.document.datatypes.FieldValue)2 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)2 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)2 PredicateFieldValue (com.yahoo.document.datatypes.PredicateFieldValue)2 RangePartition (com.yahoo.document.predicate.RangePartition)2 ExpressionAssert.assertVerifyCtx (com.yahoo.vespa.indexinglanguage.expressions.ExpressionAssert.assertVerifyCtx)2 ExpressionAssert.assertVerifyCtxThrows (com.yahoo.vespa.indexinglanguage.expressions.ExpressionAssert.assertVerifyCtxThrows)2