Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.Kryo.writeObject()


        skv.incrementIteration();
        // Serialize to a byte array in ram.
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Output ko = new Output(bos);
        Kryo kry = new Kryo();
        kry.writeObject(ko, skv);
        ko.flush();
        // Deserialize.
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        Input ki = new Input(bis);
        LazyVector des = (LazyVector)kry.readObject(ki, LazyVector.class);
View Full Code Here


        StringKeyedVector skv = buildSKV();
        // Serialize to a byte array in ram.
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Output ko = new Output(bos);
        Kryo kry = new Kryo();
        kry.writeObject(ko, skv);
        ko.flush();
        // Deserialize.
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        Input ki = new Input(bis);
        StringKeyedVector des = (StringKeyedVector)kry.readObject(ki,
View Full Code Here

        final byte[] buffer = makeBuffer();

        final CustomBean outputBean = makeBean();
        final Output output = new Output(buffer);
        kryo.writeObject(output, outputBean);

        final Input input = new Input(buffer);
        final CustomBean inputBean = kryo.readObject(input, CustomBean.class);

        assertEquals(inputBean.getSecondValue(), outputBean.getSecondValue());
View Full Code Here

        final byte[] buffer = makeBuffer();

        final CustomBean outputBean = makeBean();
        final Output output = new Output(buffer);
        kryo.writeObject(output, outputBean);

        final Input input = new Input(buffer);
        final CustomBean inputBean = kryo.readObject(input, CustomBean.class);

        assertEquals(inputBean.getFirstValue(), outputBean.getFirstValue());
View Full Code Here

    }

    private Object deserialize(Object data){
        Kryo k = KryoFactory.createInstance(store);
        Output o = new Output(1024*1024);
        k.writeObject(o,data);
        o.close();

        Input input = new Input(o.getBuffer(), 0, o.position());
        Object result = k.readObject(input,data.getClass());
        input.close();
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void kryoUnregisteredErrorTest1() {
        Kryo serial = new Kryo();
        serial.setRegistrationRequired(true);
        serial.writeObject(new Output(100), a);
    }

    @Test(expected = IllegalArgumentException.class)
    public void kryoUnregisteredErrorTest2() {
        Kryo serial = new Kryo();
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void kryoUnregisteredErrorTest2() {
        Kryo serial = new Kryo();
        serial.setRegistrationRequired(true);
        serial.writeObject(new Output(100), b);
    }

    @Test
    public void kryoUnregisteredTest() {
        Kryo serial = new Kryo();
View Full Code Here

    @Test
    public void kryoUnregisteredTest() {
        Kryo serial = new Kryo();
        serial.setRegistrationRequired(false);
        Output b1 = new Output(100), b2 = new Output(100);
        serial.writeObject(b1, a);
        serial.writeObject(b2, b);

        Input i1 = new Input(b1.getBuffer(),0,b1.position()), i2 = new Input(b2.getBuffer(),0,b2.position());
        Kryo serial2 = new Kryo();
        serial2.setRegistrationRequired(false);
View Full Code Here

    public void kryoUnregisteredTest() {
        Kryo serial = new Kryo();
        serial.setRegistrationRequired(false);
        Output b1 = new Output(100), b2 = new Output(100);
        serial.writeObject(b1, a);
        serial.writeObject(b2, b);

        Input i1 = new Input(b1.getBuffer(),0,b1.position()), i2 = new Input(b2.getBuffer(),0,b2.position());
        Kryo serial2 = new Kryo();
        serial2.setRegistrationRequired(false);
        assertTrue(Arrays.equals(b, serial2.readObject(i2, b.getClass())));
View Full Code Here

        Kryo serial3 = new Kryo();
        serial3.register(a.getClass());
        serial3.register(short[].class);
        serial3.register(TestEnum.class);
        Output b3 = new Output(100);
        serial3.writeObject(b3, a);
    }

    @Test
    public void testNumber() {
        Kryo kryo = new Kryo();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.