Search in sources :

Example 16 with Field

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

the class IndexSchemaTestCase method requireThatStructWithArrayOfArrayFieldIsFlattened.

@Test
public void requireThatStructWithArrayOfArrayFieldIsFlattened() {
    StructDataType type = new StructDataType("my_struct");
    type.addField(new Field("my_byte", DataType.getArray(DataType.getArray(DataType.BYTE))));
    type.addField(new Field("my_double", DataType.getArray(DataType.getArray(DataType.DOUBLE))));
    type.addField(new Field("my_float", DataType.getArray(DataType.getArray(DataType.FLOAT))));
    type.addField(new Field("my_int", DataType.getArray(DataType.getArray(DataType.INT))));
    type.addField(new Field("my_long", DataType.getArray(DataType.getArray(DataType.LONG))));
    type.addField(new Field("my_raw", DataType.getArray(DataType.getArray(DataType.RAW))));
    type.addField(new Field("my_string", DataType.getArray(DataType.getArray(DataType.STRING))));
    type.addField(new Field("my_uri", DataType.getArray(DataType.getArray(DataType.URI))));
    assertFlat(new Field("foo", type), new Field("foo.my_byte", DataType.getArray(DataType.getArray(DataType.BYTE))), new Field("foo.my_double", DataType.getArray(DataType.getArray(DataType.DOUBLE))), new Field("foo.my_float", DataType.getArray(DataType.getArray(DataType.FLOAT))), new Field("foo.my_int", DataType.getArray(DataType.getArray(DataType.INT))), new Field("foo.my_long", DataType.getArray(DataType.getArray(DataType.LONG))), new Field("foo.my_raw", DataType.getArray(DataType.getArray(DataType.RAW))), new Field("foo.my_string", DataType.getArray(DataType.getArray(DataType.STRING))), new Field("foo.my_uri", DataType.getArray(DataType.getArray(DataType.URI))));
}
Also used : Field(com.yahoo.document.Field) StructDataType(com.yahoo.document.StructDataType) Test(org.junit.Test)

Example 17 with Field

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

the class DocumentTypeChangeValidatorTest method createDocumentTypeWithReferenceField.

private static NewDocumentType createDocumentTypeWithReferenceField(String nameReferencedDocumentType) {
    StructDataType headerfields = new StructDataType("headerfields");
    headerfields.addField(new Field("ref", new ReferenceDataType(new DocumentType(nameReferencedDocumentType), 0)));
    return new NewDocumentType(new NewDocumentType.Name("mydoc"), headerfields, new StructDataType("bodyfields"), new FieldSets(), Collections.emptySet());
}
Also used : Field(com.yahoo.document.Field) FieldSets(com.yahoo.searchdefinition.FieldSets) ReferenceDataType(com.yahoo.document.ReferenceDataType) StructDataType(com.yahoo.document.StructDataType) DocumentType(com.yahoo.document.DocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType)

Example 18 with Field

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

the class ValidateFieldTypesTest method createSingleImportedField.

private static ImportedFields createSingleImportedField(String fieldName, DataType dataType) {
    Search targetSearch = new Search("target_doc", MockApplicationPackage.createEmpty());
    SDField targetField = new SDField("target_field", dataType);
    DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
    ImportedField importedField = new ImportedField(fieldName, documentReference, targetField);
    return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SDField(com.yahoo.searchdefinition.document.SDField) Field(com.yahoo.document.Field) ImportedField(com.yahoo.searchdefinition.document.ImportedField) SDField(com.yahoo.searchdefinition.document.SDField) Search(com.yahoo.searchdefinition.Search) ImportedField(com.yahoo.searchdefinition.document.ImportedField) ImportedFields(com.yahoo.searchdefinition.document.ImportedFields) DocumentReference(com.yahoo.searchdefinition.DocumentReference)

Example 19 with Field

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

the class ForEachTestCase method requireThatStructFieldCompatibilityIsVerified.

@Test
public void requireThatStructFieldCompatibilityIsVerified() {
    StructDataType type = new StructDataType("my_struct");
    type.addField(new Field("foo", DataType.INT));
    assertVerify(type, new ForEachExpression(new SimpleExpression()), type);
    assertVerifyThrows(type, new ForEachExpression(SimpleExpression.newConversion(DataType.STRING, DataType.INT)), "Expected string input, got int.");
    assertVerifyThrows(type, new ForEachExpression(SimpleExpression.newConversion(DataType.INT, DataType.STRING)), "Expected int output, got string.");
}
Also used : Field(com.yahoo.document.Field) StructDataType(com.yahoo.document.StructDataType) Test(org.junit.Test)

Example 20 with Field

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

the class OutputAssert method assertExecute.

public static void assertExecute(OutputExpression exp) {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter(new Field(exp.getFieldName(), DataType.STRING)));
    ctx.setValue(new StringFieldValue("69"));
    ctx.execute(exp);
    FieldValue out = ctx.getInputValue(exp.getFieldName());
    assertTrue(out instanceof StringFieldValue);
    assertEquals("69", ((StringFieldValue) out).getString());
}
Also used : Field(com.yahoo.document.Field) SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue)

Aggregations

Field (com.yahoo.document.Field)115 Test (org.junit.Test)50 StructDataType (com.yahoo.document.StructDataType)46 DocumentType (com.yahoo.document.DocumentType)24 DataType (com.yahoo.document.DataType)17 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)14 ReferenceDataType (com.yahoo.document.ReferenceDataType)13 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)13 ArrayDataType (com.yahoo.document.ArrayDataType)12 MapDataType (com.yahoo.document.MapDataType)12 TensorDataType (com.yahoo.document.TensorDataType)11 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)11 SDField (com.yahoo.searchdefinition.document.SDField)10 PositionDataType (com.yahoo.document.PositionDataType)9 FieldValue (com.yahoo.document.datatypes.FieldValue)9 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)9 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)8 Struct (com.yahoo.document.datatypes.Struct)7 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)6 Document (com.yahoo.document.Document)5