use of com.yahoo.document.datatypes.PredicateFieldValue in project vespa by vespa-engine.
the class XmlDocumentWriterTestCase method requireThatPredicateFieldValuesAreSerializedAsString.
@Test
public void requireThatPredicateFieldValuesAreSerializedAsString() {
DocumentType docType = new DocumentType("my_type");
Field field = new Field("my_predicate", DataType.PREDICATE);
docType.addField(field);
Document doc = new Document(docType, "doc:scheme:");
PredicateFieldValue predicate = Mockito.mock(PredicateFieldValue.class);
doc.setFieldValue("my_predicate", predicate);
new XmlDocumentWriter().write(doc);
Mockito.verify(predicate, Mockito.times(1)).printXml(Mockito.any(XmlStream.class));
}
use of com.yahoo.document.datatypes.PredicateFieldValue 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.datatypes.PredicateFieldValue in project vespa by vespa-engine.
the class OptimizePredicateExpression method doExecute.
@Override
protected void doExecute(ExecutionContext ctx) {
PredicateFieldValue predicate = ((PredicateFieldValue) ctx.getValue()).clone();
IntegerFieldValue arity = (IntegerFieldValue) ctx.getVariable("arity");
LongFieldValue lower_bound = (LongFieldValue) ctx.getVariable("lower_bound");
LongFieldValue upper_bound = (LongFieldValue) ctx.getVariable("upper_bound");
Long lower = lower_bound != null ? lower_bound.getLong() : null;
Long upper = upper_bound != null ? upper_bound.getLong() : null;
PredicateOptions options = new PredicateOptions(arity.getInteger(), lower, upper);
predicate.setPredicate(optimizer.process(predicate.getPredicate(), options));
ctx.setValue(predicate);
}
Aggregations