use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class SimpleAdapterFactoryTestCase method requireThatCompleteUpdatesAreCombined.
@Test
public void requireThatCompleteUpdatesAreCombined() {
DocumentType docType = new DocumentType("my_type");
DocumentUpdate update = new DocumentUpdate(docType, "doc:foo:1");
Field field1 = new Field("int1", DataType.INT);
Field field2 = new Field("int2", DataType.INT);
Field field3 = new Field("int3", DataType.INT);
docType.addField(field1);
docType.addField(field2);
docType.addField(field3);
update.addFieldUpdate(FieldUpdate.createAssign(field1, new IntegerFieldValue(10)));
update.addFieldUpdate(FieldUpdate.createAssign(field2, new IntegerFieldValue(20)));
update.addFieldUpdate(FieldUpdate.createIncrement(field3, 30));
SimpleAdapterFactory factory = new SimpleAdapterFactory();
List<UpdateAdapter> adapters = factory.newUpdateAdapterList(update);
assertEquals(2, adapters.size());
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class CompositeExpressionTestCase method requireThatToScriptBlockOutputIsParsable.
@Test
public void requireThatToScriptBlockOutputIsParsable() throws ParseException {
Expression exp = new SetValueExpression(new IntegerFieldValue(69));
assertScript("{ 69; }", exp);
assertScript("{ 69; }", new StatementExpression(exp));
assertScript("{ 69; }", new ScriptExpression(new StatementExpression(exp)));
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class RandomExpression method doExecute.
@Override
protected void doExecute(ExecutionContext ctx) {
int max;
if (this.max != null) {
max = this.max;
} else {
max = Integer.parseInt(String.valueOf(ctx.getValue()));
}
ctx.setValue(new IntegerFieldValue(ThreadLocalRandom.current().nextInt(max)));
}
use of com.yahoo.document.datatypes.IntegerFieldValue 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