Search in sources :

Example 36 with DocumentType

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

the class JsonWriterTestCase method registerMapDocumentType.

private void registerMapDocumentType() {
    DocumentType x = new DocumentType("testmap");
    DataType d = new MapDataType(DataType.STRING, DataType.STRING);
    x.addField(new Field("actualmap", d));
    types.registerDocumentType(x);
}
Also used : Field(com.yahoo.document.Field) DocumentType(com.yahoo.document.DocumentType) DataType(com.yahoo.document.DataType) ArrayDataType(com.yahoo.document.ArrayDataType) StructDataType(com.yahoo.document.StructDataType) MapDataType(com.yahoo.document.MapDataType) PositionDataType(com.yahoo.document.PositionDataType) TensorDataType(com.yahoo.document.TensorDataType) WeightedSetDataType(com.yahoo.document.WeightedSetDataType) ReferenceDataType(com.yahoo.document.ReferenceDataType) MapDataType(com.yahoo.document.MapDataType)

Example 37 with DocumentType

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

the class JsonWriterTestCase method registerPredicateDocumentType.

private void registerPredicateDocumentType() {
    DocumentType x = new DocumentType("testpredicate");
    DataType d = DataType.PREDICATE;
    x.addField(new Field("actualpredicate", d));
    types.registerDocumentType(x);
}
Also used : Field(com.yahoo.document.Field) DocumentType(com.yahoo.document.DocumentType) DataType(com.yahoo.document.DataType) ArrayDataType(com.yahoo.document.ArrayDataType) StructDataType(com.yahoo.document.StructDataType) MapDataType(com.yahoo.document.MapDataType) PositionDataType(com.yahoo.document.PositionDataType) TensorDataType(com.yahoo.document.TensorDataType) WeightedSetDataType(com.yahoo.document.WeightedSetDataType) ReferenceDataType(com.yahoo.document.ReferenceDataType)

Example 38 with DocumentType

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

the class JsonWriterTestCase method readDocumentFromJson.

private Document readDocumentFromJson(String docId, String fields) throws IOException {
    InputStream rawDoc = new ByteArrayInputStream(asFeed(docId, fields));
    JsonReader r = new JsonReader(types, rawDoc, parserFactory);
    DocumentParseInfo raw = r.parseDocument().get();
    DocumentType docType = r.readDocumentType(raw.documentId);
    DocumentPut put = new DocumentPut(new Document(docType, raw.documentId));
    new VespaJsonDocumentReader().readPut(raw.fieldsBuffer, put);
    return put.getDocument();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) DocumentParseInfo(com.yahoo.document.json.readers.DocumentParseInfo) VespaJsonDocumentReader(com.yahoo.document.json.readers.VespaJsonDocumentReader)

Example 39 with DocumentType

use of com.yahoo.document.DocumentType 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 40 with DocumentType

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

the class Bug4475379TestCase method testClone.

@Test
public void testClone() {
    DocumentTypeManager manager = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4475379.cfg");
    DocumentType type = manager.getDocumentType("blog");
    Document doc = new Document(type, "doc:this:is:a:test");
    doc.setFieldValue("body", new StringFieldValue(""));
    annotate(manager, doc);
    Document anotherDoc = doc.clone();
    assertThat(doc, equalTo(anotherDoc));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) Test(org.junit.Test)

Aggregations

DocumentType (com.yahoo.document.DocumentType)98 Test (org.junit.Test)45 Document (com.yahoo.document.Document)41 DocumentPut (com.yahoo.document.DocumentPut)35 Field (com.yahoo.document.Field)24 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)24 DocumentId (com.yahoo.document.DocumentId)20 ByteArrayInputStream (java.io.ByteArrayInputStream)19 InputStream (java.io.InputStream)19 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)17 DocumentParseInfo (com.yahoo.document.json.readers.DocumentParseInfo)17 VespaJsonDocumentReader (com.yahoo.document.json.readers.VespaJsonDocumentReader)17 DocumentUpdate (com.yahoo.document.DocumentUpdate)15 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)15 StructDataType (com.yahoo.document.StructDataType)14 TensorDataType (com.yahoo.document.TensorDataType)12 TensorFieldValue (com.yahoo.document.datatypes.TensorFieldValue)11 ArrayDataType (com.yahoo.document.ArrayDataType)10 MapDataType (com.yahoo.document.MapDataType)10 ReferenceDataType (com.yahoo.document.ReferenceDataType)10