use of com.yahoo.document.Document in project vespa by vespa-engine.
the class SerializationTestUtils method deserializeDocument.
public static Document deserializeDocument(byte[] buf, TestDocumentFactory factory) {
Document document = factory.createDocument();
DocumentDeserializerFactory.create42(factory.typeManager(), new GrowableByteBuffer(ByteBuffer.wrap(buf))).read(document);
return document;
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class SerializationTestUtils method assertDeserializeFromFile.
private static void assertDeserializeFromFile(Path path, Document document, TestDocumentFactory factory) throws IOException {
byte[] buf = Files.readAllBytes(path);
Document deserializedDocument = deserializeDocument(buf, factory);
assertEquals(path.toString(), document, deserializedDocument);
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class SerializationTestUtils method assertFieldInDocumentSerialization.
public static void assertFieldInDocumentSerialization(TestDocumentFactory documentFactory, String fieldName, FieldValue serializableFieldValue) {
Document document = documentFactory.createDocument();
document.setFieldValue(fieldName, serializableFieldValue);
byte[] buf = serializeDocument(document);
Document deserializedDocument = deserializeDocument(buf, documentFactory);
assertEquals(document, deserializedDocument);
assertEquals(serializableFieldValue, deserializedDocument.getFieldValue(fieldName));
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class TensorFieldValueSerializationTestCase method assertSerializationMatchesCpp.
private static void assertSerializationMatchesCpp(String fileName, TensorFieldValue tensor) throws IOException {
Document document = docFactory.createDocument();
document.setFieldValue(TENSOR_FIELD, tensor);
SerializationTestUtils.assertSerializationMatchesCpp(TENSOR_FILES, fileName, document, docFactory);
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class VespaDocumentSerializerTestCase method compressed_map_of_compressed_structs_is_supported.
@Test
public void compressed_map_of_compressed_structs_is_supported() {
CompressionFixture fixture = new CompressionFixture();
Document doc = new Document(fixture.docType, "id:foo:map_of_structs::flarn");
Struct nested = new Struct(fixture.nestedType);
nested.setFieldValue("str", new StringFieldValue(CompressionFixture.COMPRESSABLE_STRING));
MapFieldValue<StringFieldValue, Struct> map = new MapFieldValue<StringFieldValue, Struct>(fixture.mapType);
map.put(new StringFieldValue("foo"), nested);
map.put(new StringFieldValue("bar"), nested);
doc.setFieldValue("map", map);
// Should _not_ throw any deserialization exceptions
Document result = fixture.roundtripSerialize(doc);
assertEquals(doc, result);
}
Aggregations