use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.
the class GuardTestCase method requireThatInputFieldsAreIncludedByUpdate.
@Test
public void requireThatInputFieldsAreIncludedByUpdate() throws ParseException {
DocumentType docType = new DocumentType("my_input");
docType.addField(new Field("my_lng", DataType.LONG));
docType.addField(new Field("my_str", DataType.STRING));
DocumentUpdate docUpdate = new DocumentUpdate(docType, "doc:scheme:");
docUpdate.addFieldUpdate(FieldUpdate.createAssign(docType.getField("my_str"), new StringFieldValue("69")));
assertNotNull(docUpdate = Expression.execute(Expression.fromString("guard { input my_str | to_int | attribute my_lng }"), docUpdate));
assertEquals(0, docUpdate.getFieldPathUpdates().size());
assertEquals(1, docUpdate.getFieldUpdates().size());
FieldUpdate fieldUpd = docUpdate.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_lng"), fieldUpd.getField());
assertEquals(1, fieldUpd.getValueUpdates().size());
ValueUpdate valueUpd = fieldUpd.getValueUpdate(0);
assertNotNull(valueUpd);
assertTrue(valueUpd instanceof AssignValueUpdate);
assertEquals(new LongFieldValue(69), valueUpd.getValue());
}
use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.
the class HexEncodeTestCase method requireThatInputIsEncoded.
@Test
public void requireThatInputIsEncoded() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new LongFieldValue(489210573L));
new HexEncodeExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("1d28c2cd", ((StringFieldValue) val).getString());
}
use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.
the class HexDecodeTestCase method requireInputIsDecoded.
@Test
public void requireInputIsDecoded() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("1d28c2cd"));
new HexDecodeExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof LongFieldValue);
assertEquals(489210573L, ((LongFieldValue) val).getLong());
}
use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.
the class NowTestCase method requireThatCurrentTimeIsSet.
@Test
public void requireThatCurrentTimeIsSet() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new NowExpression(new MyTimer()).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof LongFieldValue);
assertEquals(69L, ((LongFieldValue) val).getLong());
}
use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.
the class ZCurveExpression method doExecute.
@Override
protected void doExecute(ExecutionContext ctx) {
Struct input = ((Struct) ctx.getValue());
Integer x = getFieldValue(input, PositionDataType.FIELD_X);
Integer y = getFieldValue(input, PositionDataType.FIELD_Y);
if (x != null && y != null) {
ctx.setValue(new LongFieldValue(ZCurve.encode(x, y)));
} else {
ctx.setValue(null);
}
}
Aggregations