Search in sources :

Example 6 with FieldValue

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

the class LowerCaseTestCase method requireThatStringIsLowerCased.

@Test
public void requireThatStringIsLowerCased() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("FOO"));
    new LowerCaseExpression().execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof StringFieldValue);
    assertEquals("foo", ((StringFieldValue) val).getString());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) Test(org.junit.Test)

Example 7 with FieldValue

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

the class SimpleDocumentAdapterTestCase method requireThatStructFieldsCanBeAccessed.

@Test
public void requireThatStructFieldsCanBeAccessed() {
    DataType barType = DataType.STRING;
    FieldValue bar = barType.createFieldValue("bar");
    StructDataType fooType = new StructDataType("my_struct");
    fooType.addField(new Field("bar", barType));
    Struct foo = new Struct(fooType);
    foo.setFieldValue("bar", bar);
    DocumentType docType = new DocumentType("my_doc");
    docType.addField("foo", fooType);
    Document doc = new Document(docType, "doc:scheme:");
    doc.setFieldValue("foo", foo);
    DocumentAdapter adapter = new SimpleDocumentAdapter(doc);
    assertEquals(fooType, adapter.getInputType(null, "foo"));
    assertEquals(foo, adapter.getInputValue("foo"));
    assertEquals(barType, adapter.getInputType(null, "foo.bar"));
    assertEquals(bar, adapter.getInputValue("foo.bar"));
}
Also used : FieldValue(com.yahoo.document.datatypes.FieldValue) Struct(com.yahoo.document.datatypes.Struct) Test(org.junit.Test)

Example 8 with FieldValue

use of com.yahoo.document.datatypes.FieldValue 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 9 with FieldValue

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

the class HostNameTestCase method requireThatHostnameIsSet.

@Test
public void requireThatHostnameIsSet() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    new HostNameExpression().execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof StringFieldValue);
    assertEquals(HostNameExpression.normalizeHostName(getDefaults().vespaHostname()), ((StringFieldValue) val).getString());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) Test(org.junit.Test)

Example 10 with FieldValue

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

the class MathResolverTestCase method evaluate.

private static int evaluate(Expression exp) {
    FieldValue val = new ExecutionContext(new SimpleTestAdapter()).execute(exp).getValue();
    assertTrue(val instanceof IntegerFieldValue);
    return ((IntegerFieldValue) val).getInteger();
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue)

Aggregations

FieldValue (com.yahoo.document.datatypes.FieldValue)106 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)69 Test (org.junit.Test)52 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)45 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)30 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)26 Array (com.yahoo.document.datatypes.Array)20 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)20 TensorFieldValue (com.yahoo.document.datatypes.TensorFieldValue)18 StructuredFieldValue (com.yahoo.document.datatypes.StructuredFieldValue)14 Struct (com.yahoo.document.datatypes.Struct)13 DataType (com.yahoo.document.DataType)12 Document (com.yahoo.document.Document)12 CollectionFieldValue (com.yahoo.document.datatypes.CollectionFieldValue)12 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)12 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)11 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)11 ByteArrayInputStream (java.io.ByteArrayInputStream)11 InputStream (java.io.InputStream)11 DocumentPut (com.yahoo.document.DocumentPut)10