use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JsonReaderTestCase method testMapStringToArrayOfInt.
@Test
public final void testMapStringToArrayOfInt() throws IOException {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"put\": \"id:unittest:testMapStringToArrayOfInt::whee\"," + " \"fields\": { \"actualMapStringToArrayOfInt\": { \"bamse\": [1, 2, 3] }}}"));
JsonReader r = new JsonReader(types, rawDoc, parserFactory);
DocumentParseInfo parseInfo = r.parseDocument().get();
DocumentType docType = r.readDocumentType(parseInfo.documentId);
DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
Document doc = put.getDocument();
FieldValue f = doc.getFieldValue("actualMapStringToArrayOfInt");
assertSame(MapFieldValue.class, f.getClass());
MapFieldValue<?, ?> m = (MapFieldValue<?, ?>) f;
Array<?> a = (Array<?>) m.get(new StringFieldValue("bamse"));
assertEquals(3, a.size());
assertEquals(new IntegerFieldValue(1), a.get(0));
assertEquals(new IntegerFieldValue(2), a.get(1));
assertEquals(new IntegerFieldValue(3), a.get(2));
}
use of com.yahoo.document.DocumentType 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;
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class VespaXmlUpdateReaderTestCase method readUpdateHelper.
private static DocumentUpdate readUpdateHelper(Field field, String documentXml) throws Exception {
DocumentTypeManager docManager = new DocumentTypeManager();
DocumentType docType = new DocumentType("my_type");
if (field != null) {
docType.addField(field);
}
docManager.register(docType);
InputStream in = new ByteArrayInputStream(documentXml.getBytes(StandardCharsets.UTF_8));
DocumentUpdate doc = new DocumentUpdate(docType, "doc:scheme:");
VespaXMLUpdateReader reader = new VespaXMLUpdateReader(in, docManager);
// initialize reader
reader.reader.next();
reader.read(doc);
return doc;
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JsonWriterTestCase method registerArrayDocumentType.
private void registerArrayDocumentType() {
DocumentType x = new DocumentType("testarray");
DataType d = new ArrayDataType(DataType.STRING);
x.addField(new Field("actualarray", d));
types.registerDocumentType(x);
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JsonWriterTestCase method registerSmokeDocumentType.
private void registerSmokeDocumentType() {
DocumentType x = new DocumentType("smoke");
x.addField(new Field("something", DataType.STRING));
x.addField(new Field("nalle", DataType.STRING));
types.registerDocumentType(x);
}
Aggregations