Search in sources :

Example 1 with TensorDataType

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

the class TensorFieldProcessor method process.

@Override
public void process(boolean validate) {
    if (!validate)
        return;
    for (SDField field : search.allConcreteFields()) {
        if (field.getDataType() instanceof TensorDataType) {
            validateIndexingScripsForTensorField(field);
            validateAttributeSettingForTensorField(field);
        } else if (field.getDataType() instanceof CollectionDataType) {
            validateDataTypeForCollectionField(field);
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) TensorDataType(com.yahoo.document.TensorDataType) CollectionDataType(com.yahoo.document.CollectionDataType)

Example 2 with TensorDataType

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

the class TensorFieldValueSerializationTestCase method createDocType.

private static DocumentType createDocType() {
    DocumentType type = new DocumentType("my_type");
    type.addField(TENSOR_FIELD, new TensorDataType(tensorType));
    return type;
}
Also used : TensorDataType(com.yahoo.document.TensorDataType) DocumentType(com.yahoo.document.DocumentType)

Example 3 with TensorDataType

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

the class JsonWriterTestCase method registerTensorDocumentType.

private void registerTensorDocumentType() {
    DocumentType x = new DocumentType("testtensor");
    TensorType tensorType = new TensorType.Builder().mapped("x").mapped("y").build();
    x.addField(new Field("tensorfield", new TensorDataType(tensorType)));
    types.registerDocumentType(x);
}
Also used : Field(com.yahoo.document.Field) TensorDataType(com.yahoo.document.TensorDataType) DocumentType(com.yahoo.document.DocumentType) TensorType(com.yahoo.tensor.TensorType)

Example 4 with TensorDataType

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

the class JsonReaderTestCase method setUp.

@Before
public void setUp() throws Exception {
    parserFactory = new JsonFactory();
    types = new DocumentTypeManager();
    {
        DocumentType x = new DocumentType("smoke");
        x.addField(new Field("something", DataType.STRING));
        x.addField(new Field("nalle", DataType.STRING));
        x.addField(new Field("int1", DataType.INT));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("mirrors");
        StructDataType woo = new StructDataType("woo");
        woo.addField(new Field("sandra", DataType.STRING));
        woo.addField(new Field("cloud", DataType.STRING));
        x.addField(new Field("skuggsjaa", woo));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testarray");
        DataType d = new ArrayDataType(DataType.STRING);
        x.addField(new Field("actualarray", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testset");
        DataType d = new WeightedSetDataType(DataType.STRING, true, true);
        x.addField(new Field("actualset", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testmap");
        DataType d = new MapDataType(DataType.STRING, DataType.STRING);
        x.addField(new Field("actualmap", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testraw");
        DataType d = DataType.RAW;
        x.addField(new Field("actualraw", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testMapStringToArrayOfInt");
        DataType value = new ArrayDataType(DataType.INT);
        DataType d = new MapDataType(DataType.STRING, value);
        x.addField(new Field("actualMapStringToArrayOfInt", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testsinglepos");
        DataType d = PositionDataType.INSTANCE;
        x.addField(new Field("singlepos", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testtensor");
        x.addField(new Field("mappedtensorfield", new TensorDataType(new TensorType.Builder().mapped("x").mapped("y").build())));
        x.addField(new Field("indexedtensorfield", new TensorDataType(new TensorType.Builder().indexed("x").indexed("y").build())));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testpredicate");
        x.addField(new Field("boolean", DataType.PREDICATE));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testint");
        x.addField(new Field("integerfield", DataType.INT));
        types.registerDocumentType(x);
    }
}
Also used : Field(com.yahoo.document.Field) TensorDataType(com.yahoo.document.TensorDataType) StructDataType(com.yahoo.document.StructDataType) WeightedSetDataType(com.yahoo.document.WeightedSetDataType) JsonFactory(com.fasterxml.jackson.core.JsonFactory) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) DataType(com.yahoo.document.DataType) MapDataType(com.yahoo.document.MapDataType) TensorDataType(com.yahoo.document.TensorDataType) WeightedSetDataType(com.yahoo.document.WeightedSetDataType) ArrayDataType(com.yahoo.document.ArrayDataType) StructDataType(com.yahoo.document.StructDataType) PositionDataType(com.yahoo.document.PositionDataType) MapDataType(com.yahoo.document.MapDataType) ArrayDataType(com.yahoo.document.ArrayDataType) TensorType(com.yahoo.tensor.TensorType) Before(org.junit.Before)

Example 5 with TensorDataType

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

the class JsonWriterTestCase method testWritingOfTensorFieldValueWithoutTensor.

@Test
public void testWritingOfTensorFieldValueWithoutTensor() throws IOException {
    DocumentType documentTypeWithTensor = types.getDocumentType("testtensor");
    String docId = "id:unittest:testtensor::0";
    Document doc = new Document(documentTypeWithTensor, docId);
    Field tensorField = documentTypeWithTensor.getField("tensorfield");
    doc.setFieldValue(tensorField, new TensorFieldValue(((TensorDataType) tensorField.getDataType()).getTensorType()));
    assertEqualJson(asDocument(docId, "{ \"tensorfield\": {} }"), JsonWriter.toByteArray(doc));
}
Also used : TensorFieldValue(com.yahoo.document.datatypes.TensorFieldValue) Field(com.yahoo.document.Field) TensorDataType(com.yahoo.document.TensorDataType) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) Test(org.junit.Test)

Aggregations

TensorDataType (com.yahoo.document.TensorDataType)5 DocumentType (com.yahoo.document.DocumentType)4 Field (com.yahoo.document.Field)3 TensorType (com.yahoo.tensor.TensorType)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 ArrayDataType (com.yahoo.document.ArrayDataType)1 CollectionDataType (com.yahoo.document.CollectionDataType)1 DataType (com.yahoo.document.DataType)1 Document (com.yahoo.document.Document)1 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)1 MapDataType (com.yahoo.document.MapDataType)1 PositionDataType (com.yahoo.document.PositionDataType)1 StructDataType (com.yahoo.document.StructDataType)1 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)1 TensorFieldValue (com.yahoo.document.datatypes.TensorFieldValue)1 SDField (com.yahoo.searchdefinition.document.SDField)1 Before (org.junit.Before)1 Test (org.junit.Test)1