Search in sources :

Example 1 with IntegerFieldValue

use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.

the class ExpressionTestCase method requireThatInputTypeIsCheckedBeforeExecute.

@Test
public void requireThatInputTypeIsCheckedBeforeExecute() {
    assertExecute(newRequiredInput(DataType.INT), null);
    assertExecute(newRequiredInput(DataType.INT), new IntegerFieldValue(69));
    assertExecuteThrows(newRequiredInput(DataType.INT), new StringFieldValue("foo"), new IllegalArgumentException("expected int input, got string"));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 2 with IntegerFieldValue

use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.

the class GetVarTestCase method requireThatSymbolIsRead.

@Test
public void requireThatSymbolIsRead() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setVariable("in", new IntegerFieldValue(69));
    new GetVarExpression("in").execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof IntegerFieldValue);
    assertEquals(69, ((IntegerFieldValue) val).getInteger());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 3 with IntegerFieldValue

use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.

the class DocumentToPathUpdateTestCase method requireThatStructAssignIsConverted.

@Test
public void requireThatStructAssignIsConverted() {
    DocumentType docType = new DocumentType("my_type");
    StructDataType structType = new StructDataType("my_struct");
    structType.addField(new Field("b", DataType.INT));
    docType.addField(new Field("a", structType));
    Struct struct = structType.createFieldValue();
    struct.setFieldValue("b", new IntegerFieldValue(69));
    FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "a", "", struct);
    Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
    assertNotNull(doc);
    FieldValue obj = doc.getFieldValue("a");
    assertTrue(obj instanceof Struct);
    struct = (Struct) obj;
    struct.setFieldValue("b", new IntegerFieldValue(96));
    DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
    assertNotNull(docUpd);
    assertEquals(1, docUpd.getFieldPathUpdates().size());
    assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
    assertTrue(upd instanceof AssignFieldPathUpdate);
    assertEquals("a", upd.getOriginalFieldPath());
    assertEquals(struct, ((AssignFieldPathUpdate) upd).getNewValue());
}
Also used : IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate) FieldPathUpdate(com.yahoo.document.fieldpathupdate.FieldPathUpdate) Struct(com.yahoo.document.datatypes.Struct) Test(org.junit.Test)

Example 4 with IntegerFieldValue

use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.

the class DocumentToPathUpdateTestCase method requireThatIntegerAssignIsConverted.

@Test
public void requireThatIntegerAssignIsConverted() {
    DocumentType docType = new DocumentType("my_type");
    docType.addField(new Field("my_int", DataType.INT));
    FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "my_int", "", new IntegerFieldValue(69));
    Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
    assertNotNull(doc);
    doc.setFieldValue("my_int", new IntegerFieldValue(96));
    DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
    assertNotNull(docUpd);
    assertEquals(1, docUpd.getFieldPathUpdates().size());
    assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
    assertTrue(upd instanceof AssignFieldPathUpdate);
    assertEquals("my_int", upd.getOriginalFieldPath());
    assertEquals(new IntegerFieldValue(96), ((AssignFieldPathUpdate) upd).getNewValue());
}
Also used : IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate) FieldPathUpdate(com.yahoo.document.fieldpathupdate.FieldPathUpdate) Test(org.junit.Test)

Example 5 with IntegerFieldValue

use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.

the class DocumentToPathUpdateTestCase method requireThatStructElementAssignIsConverted.

@Test
public void requireThatStructElementAssignIsConverted() {
    DocumentType docType = new DocumentType("my_type");
    StructDataType structType = new StructDataType("my_struct");
    structType.addField(new Field("b", DataType.INT));
    docType.addField(new Field("a", structType));
    FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "a.b", "", new IntegerFieldValue(69));
    Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
    assertNotNull(doc);
    FieldValue obj = doc.getFieldValue("a");
    assertTrue(obj instanceof Struct);
    Struct struct = (Struct) obj;
    struct.setFieldValue("b", new IntegerFieldValue(96));
    DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
    assertNotNull(docUpd);
    assertEquals(1, docUpd.getFieldPathUpdates().size());
    assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
    assertTrue(upd instanceof AssignFieldPathUpdate);
    assertEquals("a.b", upd.getOriginalFieldPath());
    obj = ((AssignFieldPathUpdate) upd).getNewValue();
    assertTrue(obj instanceof IntegerFieldValue);
    assertEquals(96, ((IntegerFieldValue) obj).getInteger());
}
Also used : IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate) FieldPathUpdate(com.yahoo.document.fieldpathupdate.FieldPathUpdate) Struct(com.yahoo.document.datatypes.Struct) Test(org.junit.Test)

Aggregations

IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)69 Test (org.junit.Test)56 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)39 FieldValue (com.yahoo.document.datatypes.FieldValue)23 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)14 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)13 Array (com.yahoo.document.datatypes.Array)12 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)10 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)10 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)10 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)10 Struct (com.yahoo.document.datatypes.Struct)10 Field (com.yahoo.document.Field)8 DocumentType (com.yahoo.document.DocumentType)7 WeightedSet (com.yahoo.document.datatypes.WeightedSet)7 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)7 Document (com.yahoo.document.Document)5 DocumentUpdate (com.yahoo.document.DocumentUpdate)5 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)4 PredicateFieldValue (com.yahoo.document.datatypes.PredicateFieldValue)4