Search in sources :

Example 71 with GrowableByteBuffer

use of com.yahoo.io.GrowableByteBuffer in project vespa by vespa-engine.

the class DocumentUpdateTestCase method testThatAssignValueUpdateForTensorFieldCanBeSerializedAndDeserialized.

public void testThatAssignValueUpdateForTensorFieldCanBeSerializedAndDeserialized() {
    DocumentUpdate serializedUpdate = createTensorAssignUpdate();
    DocumentSerializer serializer = DocumentSerializerFactory.createHead(new GrowableByteBuffer());
    serializedUpdate.serialize(serializer);
    serializer.getBuf().flip();
    DocumentDeserializer deserializer = DocumentDeserializerFactory.createHead(docMan, serializer.getBuf());
    DocumentUpdate deserializedUpdate = new DocumentUpdate(deserializer);
    assertEquals(serializedUpdate, deserializedUpdate);
}
Also used : GrowableByteBuffer(com.yahoo.io.GrowableByteBuffer)

Example 72 with GrowableByteBuffer

use of com.yahoo.io.GrowableByteBuffer in project vespa by vespa-engine.

the class AlternateSpanListTestCase method serializeAndAssert.

private void serializeAndAssert(AlternateSpanList alternateSpanList) {
    GrowableByteBuffer buffer;
    {
        buffer = new GrowableByteBuffer(1024);
        DocumentSerializer serializer = DocumentSerializerFactory.create42(buffer);
        StringFieldValue value = new StringFieldValue("lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lk");
        SpanTree tree = new SpanTree("bababa", alternateSpanList);
        value.setSpanTree(tree);
        serializer.write(null, value);
        buffer.flip();
    }
    AlternateSpanList alternateSpanList2;
    {
        DocumentDeserializer deserializer = DocumentDeserializerFactory.create42(man, buffer);
        StringFieldValue value = new StringFieldValue();
        deserializer.read(null, value);
        alternateSpanList2 = (AlternateSpanList) value.getSpanTree("bababa").getRoot();
    }
    assertEquals(alternateSpanList, alternateSpanList2);
    assertNotSame(alternateSpanList, alternateSpanList2);
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) GrowableByteBuffer(com.yahoo.io.GrowableByteBuffer)

Example 73 with GrowableByteBuffer

use of com.yahoo.io.GrowableByteBuffer in project vespa by vespa-engine.

the class Bug4261985TestCase method testAnnotate.

@Test
public void testAnnotate() {
    DocumentTypeManager manager = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4261985.cfg");
    DocumentType type = manager.getDocumentType("blog");
    Document doc = new Document(type, "doc:this:is:a:test");
    doc.setFieldValue("body", new StringFieldValue("bla bla bla bla bla bla bla" + "bla bla bla bla bla bla bla"));
    annotate(doc, manager);
    GrowableByteBuffer buf = new GrowableByteBuffer();
    doc.serialize(buf);
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) GrowableByteBuffer(com.yahoo.io.GrowableByteBuffer) Document(com.yahoo.document.Document) Test(org.junit.Test)

Example 74 with GrowableByteBuffer

use of com.yahoo.io.GrowableByteBuffer in project vespa by vespa-engine.

the class Bug4259784TestCase method testSerialize.

@Test
public void testSerialize() {
    DocumentTypeManager manager = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4259784.cfg");
    DocumentType type = manager.getDocumentType("blog");
    Document doc = new Document(type, "doc:this:is:a:test");
    doc.setFieldValue("body", new StringFieldValue("bla bla bla bla bla bla bla" + "bla bla bla bla bla bla bla"));
    annotate(doc, manager);
    GrowableByteBuffer buf = new GrowableByteBuffer();
    doc.serialize(buf);
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) GrowableByteBuffer(com.yahoo.io.GrowableByteBuffer) Document(com.yahoo.document.Document) Test(org.junit.Test)

Aggregations

GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)74 Test (org.junit.Test)34 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)18 Document (com.yahoo.document.Document)9 BufferSerializer (com.yahoo.vespa.objects.BufferSerializer)9 Field (com.yahoo.document.Field)8 ByteBuffer (java.nio.ByteBuffer)8 FileOutputStream (java.io.FileOutputStream)6 DocumentType (com.yahoo.document.DocumentType)5 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)5 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)5 AbstractTypesTest (com.yahoo.document.annotation.AbstractTypesTest)4 Raw (com.yahoo.document.datatypes.Raw)4 Struct (com.yahoo.document.datatypes.Struct)4 Grouping (com.yahoo.searchlib.aggregation.Grouping)4 Array (com.yahoo.document.datatypes.Array)3 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)3 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)3 FieldUpdate (com.yahoo.document.update.FieldUpdate)3 IOException (java.io.IOException)3