use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class PredicateTreeAnnotatorTest method require_that_featureconjunctions_are_registered_and_given_an_interval.
@Test
public void require_that_featureconjunctions_are_registered_and_given_an_interval() {
Predicate p = and(or(range("key", partition("key=10-19"), partition("key=20-29"), edgePartition("key=0", 5, 10, 20), edgePartition("key=30", 0, 0, 3)), conj(not(feature("keyA").inSet("C")), feature("keyB").inSet("D"))), feature("foo").inSet("bar"));
PredicateTreeAnnotations r = PredicateTreeAnnotator.createPredicateTreeAnnotations(p);
assertEquals(2, r.minFeature);
assertEquals(3, r.intervalEnd);
assertEquals(3, r.intervalMap.size());
assertEquals(2, r.boundsMap.size());
assertEquals(1, r.featureConjunctions.size());
Map.Entry<IndexableFeatureConjunction, List<Integer>> entry = r.featureConjunctions.entrySet().iterator().next();
assertEquals(1, entry.getValue().size());
assertEquals(0b1_0000000000000010, entry.getValue().get(0).longValue());
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class BooleanSimplifierTest method assertSimplifiedTo.
private void assertSimplifiedTo(Predicate expected, Predicate input) {
BooleanSimplifier simplifier = new BooleanSimplifier();
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 VespaFeedParser method parseDocuments.
public static int parseDocuments(String feedFile, int maxDocuments, Consumer<Predicate> consumer) throws IOException {
int documentCount = 0;
try (BufferedReader reader = new BufferedReader(new FileReader(feedFile), 8 * 1024)) {
reader.readLine();
// Skip to start of first document
reader.readLine();
String line = reader.readLine();
while (!line.startsWith("</vespafeed>") && documentCount < maxDocuments) {
while (!line.startsWith("<boolean>")) {
line = reader.readLine();
}
Predicate predicate = Predicate.fromString(extractBooleanExpression(line));
consumer.accept(predicate);
++documentCount;
while (!line.startsWith("<document") && !line.startsWith("</vespafeed>")) {
line = reader.readLine();
}
}
}
return documentCount;
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class PredicateFieldValueTest method requireThatConstructorsWork.
@Test
public void requireThatConstructorsWork() {
assertNull(new PredicateFieldValue().getPredicate());
Predicate predicate = SimplePredicates.newPredicate();
assertEquals(predicate, new PredicateFieldValue(predicate).getPredicate());
}
use of com.yahoo.document.predicate.Predicate in project vespa by vespa-engine.
the class ComplexNodeTransformerTest method testConvert.
private void testConvert(String predicate, String expected, int arity) {
Predicate p = Predicate.fromString(predicate);
ComplexNodeTransformer transformer = new ComplexNodeTransformer();
Predicate converted = transformer.process(p, new PredicateOptions(arity, lowerBound, upperBound));
assertEquals(expected, converted.toString());
}
Aggregations