use of com.esotericsoftware.kryo.io.Output in project heron by twitter.
the class KryoSerializer method initialize.
@Override
public void initialize(Map<String, Object> config) {
kryo = new Kryo();
kryo.setReferences(false);
kryoOut = new Output(2000, 2000000000);
kryoIn = new Input(1);
}
use of com.esotericsoftware.kryo.io.Output in project heron by twitter.
the class HeronPluggableSerializerDelegate method initialize.
@Override
@SuppressWarnings("rawtypes")
public void initialize(Map config) {
kryo = SerializationFactory.getKryo(config);
kryoOut = new Output(2000, 2000000000);
kryoIn = new Input(1);
}
use of com.esotericsoftware.kryo.io.Output in project jetcache by alibaba.
the class KryoValueEncoder method apply.
@Override
public byte[] apply(Object value) {
try {
Kryo kryo = kryoThreadLocal.get();
ByteArrayOutputStream bos = new ByteArrayOutputStream(256);
Output output = new Output(bos);
output.writeInt(IDENTITY_NUMBER);
kryo.writeClassAndObject(output, value);
output.close();
return bos.toByteArray();
} catch (Exception e) {
StringBuilder sb = new StringBuilder("Kryo Encode error. ");
sb.append("msg=").append(e.getMessage());
throw new CacheEncodeException(sb.toString(), e);
}
}
use of com.esotericsoftware.kryo.io.Output in project apex-core by apache.
the class DefaultStatefulStreamCodecTest method testVirginKryo.
@Test
public void testVirginKryo() {
Kryo coder = new Kryo();
Kryo decoder = new Kryo();
ClassIdPair cip = new ClassIdPair();
Output output = new Output(4096, Integer.MAX_VALUE);
coder.writeClassAndObject(output, cip);
Input input = new Input();
input.setBuffer(output.toBytes());
decoder.readClassAndObject(input);
}
use of com.esotericsoftware.kryo.io.Output in project apex-core by apache.
the class OperatorDiscoveryTest method testTypeGraphSerializer.
@Test
public void testTypeGraphSerializer() throws Exception {
String[] classFilePath = getClassFileInClasspath();
OperatorDiscoverer operatorDiscoverer = new OperatorDiscoverer(classFilePath);
operatorDiscoverer.buildTypeGraph();
// make sure (de)serialization of type graph works without problem
Kryo kryo = new Kryo();
TypeGraph.TypeGraphSerializer tgs = new TypeGraph.TypeGraphSerializer();
kryo.register(TypeGraph.class, tgs);
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024 * 1024 * 20);
Output output = new Output(baos);
kryo.writeObject(output, operatorDiscoverer.getTypeGraph());
output.close();
Input input = new Input(new ByteArrayInputStream(baos.toByteArray()));
TypeGraph tg = kryo.readObject(input, TypeGraph.class);
}
Aggregations