use of com.yahoo.vespa.objects.BufferSerializer in project vespa by vespa-engine.
the class GroupingTestCase method assertSerialize.
private static void assertSerialize(Grouping grouping) {
BufferSerializer buf = new BufferSerializer();
grouping.serializeWithId(buf);
buf.flip();
Grouping other = (Grouping) Grouping.create(buf);
assertEquals(grouping, other);
}
use of com.yahoo.vespa.objects.BufferSerializer in project vespa by vespa-engine.
the class SparseSketchTest method requireThatSerializationRetainAllData.
@Test
public void requireThatSerializationRetainAllData() {
SparseSketch from = new SparseSketch();
from.aggregate(42);
from.aggregate(1337);
SparseSketch to = new SparseSketch();
BufferSerializer buffer = new BufferSerializer();
from.serialize(buffer);
buffer.flip();
to.deserialize(buffer);
assertEquals(from, to);
}
use of com.yahoo.vespa.objects.BufferSerializer in project vespa by vespa-engine.
the class ExpressionTestCase method assertSerialize.
private static Identifiable assertSerialize(Identifiable node) {
BufferSerializer buf = new BufferSerializer(new GrowableByteBuffer());
node.serializeWithId(buf);
buf.flip();
Identifiable created = Identifiable.create(buf);
assertEquals(node, created);
assertEquals(buf.getBuf().hasRemaining(), false);
Identifiable cloned = created.clone();
assertEquals(node, cloned);
BufferSerializer createdBuffer = new BufferSerializer(new GrowableByteBuffer());
BufferSerializer clonedBuffer = new BufferSerializer(new GrowableByteBuffer());
created.serializeWithId(createdBuffer);
cloned.serializeWithId(clonedBuffer);
assertEquals(createdBuffer.getBuf().limit(), clonedBuffer.getBuf().limit());
assertEquals(createdBuffer.position(), clonedBuffer.position());
createdBuffer.getBuf().flip();
clonedBuffer.getBuf().flip();
for (int i = 0; i < createdBuffer.getBuf().limit(); i++) {
assertEquals(createdBuffer.getBuf().get(), clonedBuffer.getBuf().get());
}
return created;
}
use of com.yahoo.vespa.objects.BufferSerializer in project vespa by vespa-engine.
the class ExpressionTestCase method assertResultNode.
private static void assertResultNode(ResultNode node) {
BufferSerializer buf = new BufferSerializer(new GrowableByteBuffer());
long oldInteger = node.getInteger();
double oldFloat = node.getFloat();
String oldString = node.getString();
byte[] oldRaw = node.getRaw();
node.serialize(buf);
buf.flip();
node.deserialize(buf);
assertEquals(oldInteger, node.getInteger());
assertEquals(oldFloat, node.getFloat());
assertEquals(oldString, node.getString());
assertEquals(oldRaw.length, node.getRaw().length);
buf = new BufferSerializer(new GrowableByteBuffer());
node.serializeWithId(buf);
buf.flip();
node.deserializeWithId(buf);
assertEquals(oldInteger, node.getInteger());
assertEquals(oldFloat, node.getFloat());
assertEquals(oldString, node.getString());
assertEquals(oldRaw.length, node.getRaw().length);
buf = new BufferSerializer(new GrowableByteBuffer());
node.serializeWithId(buf);
buf.flip();
ResultNode obj = (ResultNode) Identifiable.create(buf);
assertEquals(oldInteger, obj.getInteger());
assertEquals(oldFloat, obj.getFloat());
assertEquals(oldString, obj.getString());
assertEquals(oldRaw.length, obj.getRaw().length);
assertSerialize(node);
}
use of com.yahoo.vespa.objects.BufferSerializer in project vespa by vespa-engine.
the class ResultNodeTest method assertCorrectSerialization.
public void assertCorrectSerialization(ResultNode from, ResultNode to) {
BufferSerializer buffer = new BufferSerializer();
from.serialize(buffer);
buffer.flip();
to.deserialize(buffer);
assertThat(from.onCmp(to), is(0));
}
Aggregations