use of com.esotericsoftware.kryo.io.Output in project quasar by puniverse.
the class KryoSerializer method write.
@Override
public void write(OutputStream os, Object object) {
final Output out = getOutput();
out.clear();
out.setOutputStream(os);
kryo.writeClassAndObject(out, object);
out.flush();
out.setOutputStream(null);
}
use of com.esotericsoftware.kryo.io.Output in project quasar by puniverse.
the class KryoSerializer method write.
@Override
public byte[] write(Object object) {
final Output out = getOutput();
out.clear();
kryo.writeClassAndObject(out, object);
out.flush();
return out.toBytes();
}
use of com.esotericsoftware.kryo.io.Output in project Gaffer by gchq.
the class RegistratorTest method testEntity.
@Test
public void testEntity() {
// Given
Entity entity = new Entity("group");
entity.setVertex("abc");
entity.putProperty("property1", 1);
// When
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
kryo.writeObject(output, entity);
output.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
Input input = new Input(bais);
Entity read = kryo.readObject(input, Entity.class);
input.close();
// Then
assertEquals(entity, read);
}
use of com.esotericsoftware.kryo.io.Output in project Gaffer by gchq.
the class RegistratorTest method testEdge.
@Test
public void testEdge() {
// Given
Edge edge = new Edge("group");
edge.setSource("abc");
edge.setDestination("xyz");
edge.setDirected(true);
edge.putProperty("property1", 1);
// When
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
kryo.writeObject(output, edge);
output.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
Input input = new Input(bais);
Edge read = kryo.readObject(input, Edge.class);
input.close();
// Then
assertEquals(edge, read);
}
use of com.esotericsoftware.kryo.io.Output in project MantaroBot by Mantaro.
the class KryoUtils method serialize.
public static byte[] serialize(Kryo kryo, Object obj) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output out = new Output(baos);
checkNotNull(kryo, "kryo").writeClassAndObject(out, obj);
out.close();
return baos.toByteArray();
}
Aggregations