Search in sources :

Example 1 with LongFieldValue

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());
}
Also used : ValueUpdate(com.yahoo.document.update.ValueUpdate) AssignValueUpdate(com.yahoo.document.update.AssignValueUpdate) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldUpdate(com.yahoo.document.update.FieldUpdate) AssignValueUpdate(com.yahoo.document.update.AssignValueUpdate) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 2 with LongFieldValue

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());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 3 with LongFieldValue

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());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 4 with LongFieldValue

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());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 5 with LongFieldValue

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);
    }
}
Also used : LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Struct(com.yahoo.document.datatypes.Struct)

Aggregations

LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)25 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)17 Test (org.junit.Test)17 FieldValue (com.yahoo.document.datatypes.FieldValue)9 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)8 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)7 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)6 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)6 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)6 Raw (com.yahoo.document.datatypes.Raw)4 WeightedSet (com.yahoo.document.datatypes.WeightedSet)4 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)4 Array (com.yahoo.document.datatypes.Array)3 ByteBuffer (java.nio.ByteBuffer)3 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)2 PredicateFieldValue (com.yahoo.document.datatypes.PredicateFieldValue)2 FileOutputStream (java.io.FileOutputStream)2 DataType (com.yahoo.document.DataType)1 AbstractTypesTest (com.yahoo.document.annotation.AbstractTypesTest)1 Struct (com.yahoo.document.datatypes.Struct)1