Search in sources :

Example 36 with Output

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);
}
Also used : Input(com.esotericsoftware.kryo.io.Input) Output(com.esotericsoftware.kryo.io.Output) Kryo(com.esotericsoftware.kryo.Kryo)

Example 37 with Output

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);
}
Also used : Input(com.esotericsoftware.kryo.io.Input) Output(com.esotericsoftware.kryo.io.Output)

Example 38 with Output

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);
    }
}
Also used : Output(com.esotericsoftware.kryo.io.Output) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Kryo(com.esotericsoftware.kryo.Kryo)

Example 39 with Output

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);
}
Also used : Input(com.esotericsoftware.kryo.io.Input) Output(com.esotericsoftware.kryo.io.Output) ClassIdPair(com.datatorrent.stram.codec.DefaultStatefulStreamCodec.ClassIdPair) Kryo(com.esotericsoftware.kryo.Kryo) Test(org.junit.Test)

Example 40 with Output

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);
}
Also used : Input(com.esotericsoftware.kryo.io.Input) ByteArrayInputStream(java.io.ByteArrayInputStream) Output(com.esotericsoftware.kryo.io.Output) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Kryo(com.esotericsoftware.kryo.Kryo) Test(org.junit.Test)

Aggregations

Output (com.esotericsoftware.kryo.io.Output)51 Kryo (com.esotericsoftware.kryo.Kryo)29 ByteArrayOutputStream (java.io.ByteArrayOutputStream)22 Input (com.esotericsoftware.kryo.io.Input)21 ByteArrayInputStream (java.io.ByteArrayInputStream)12 Test (org.junit.Test)8 FileOutputStream (java.io.FileOutputStream)7 Test (org.testng.annotations.Test)6 IOException (java.io.IOException)5 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)5 KryoException (com.esotericsoftware.kryo.KryoException)4 StdInstantiatorStrategy (org.objenesis.strategy.StdInstantiatorStrategy)4 SAMFileHeader (htsjdk.samtools.SAMFileHeader)3 Schema (co.cask.cdap.api.data.schema.Schema)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 HashMap (java.util.HashMap)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 StructuredRecord (co.cask.cdap.api.data.format.StructuredRecord)1 ClassIdPair (com.datatorrent.stram.codec.DefaultStatefulStreamCodec.ClassIdPair)1