Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.Output


      long start = System.nanoTime();

      for (int j = 0; j < ITER_CNT; j++) {

        Output kryoOut = null;

        kryoOut = new Output(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new Input(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here


      long start = System.nanoTime();

      for (int j = 0; j < ITER_CNT; j++) {

        Output kryoOut = null;

        kryoOut = new FastOutput(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new FastInput(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here

      long start = System.nanoTime();

      for (int j = 0; j < ITER_CNT; j++) {

        Output kryoOut = null;

        kryoOut = new UnsafeOutput(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new UnsafeInput(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here

      long start = System.nanoTime();

      for (int j = 0; j < ITER_CNT; j++) {

        Output kryoOut = null;

        kryoOut = new UnsafeOutput(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new UnsafeInput(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here

      long start = System.nanoTime();

      for (int j = 0; j < ITER_CNT; j++) {

        Output kryoOut = null;

        kryoOut = new UnsafeOutput(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new UnsafeInput(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here

    assertEquals(true, read.eof());
  }

  public void testSimpleVarInt() {
      final int value = 39117;
      final Output out = new UnsafeOutput(1024);
      out.writeVarInt(value, true);
      out.flush();
      final Input in = new UnsafeInput(out.toBytes());
      final int actualValue = in.readVarInt(true);
      assertEquals(value, actualValue);
  }
View Full Code Here

 
  public void testClassSerializer() {
    kryo.register(Class.class);
    kryo.register(ArrayList.class);
    kryo.setRegistrationRequired(false);
    final Output out = new Output(1024);

    kryo.writeObject(out, String.class);
    kryo.writeObject(out, Integer.class);
    kryo.writeObject(out, Short.class);
    kryo.writeObject(out, Long.class);
    kryo.writeObject(out, Double.class);
    kryo.writeObject(out, Float.class);
    kryo.writeObject(out, Boolean.class);
    kryo.writeObject(out, Character.class);
    kryo.writeObject(out, Void.class);

    kryo.writeObject(out, int.class);
    kryo.writeObject(out, short.class);
    kryo.writeObject(out, long.class);
    kryo.writeObject(out, double.class);
    kryo.writeObject(out, float.class);
    kryo.writeObject(out, boolean.class);
    kryo.writeObject(out, char.class);
    kryo.writeObject(out, void.class);
    kryo.writeObject(out, ArrayList.class);
    kryo.writeObject(out, TestEnum.class);

    final Input in = new Input(out.getBuffer());

    assertEquals(String.class, kryo.readObject(in, Class.class));
    assertEquals(Integer.class, kryo.readObject(in, Class.class));
    assertEquals(Short.class, kryo.readObject(in, Class.class));
    assertEquals(Long.class, kryo.readObject(in, Class.class));
View Full Code Here

      }
    });
   
    return roundTripWithStreamFactory(length, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
        return new Output(os);
      }

      public Output createOutput(OutputStream os, int size) {
        return new Output(os, size);
      }

      public Output createOutput(int size, int limit) {
        return new Output(size, limit);
      }

      public Input createInput(InputStream os, int size) {
        return new Input(os, size);
      }
View Full Code Here

    kryo.register(HashMap.class);

    HasGenerics test = new HasGenerics();
    test.map.put("moo", new Integer[] {1, 2});

    output = new Output(4096);
    kryo.writeClassAndObject(output, test);
    output.flush();

    input = new Input(output.toBytes());
    HasGenerics test2 = (HasGenerics)kryo.readClassAndObject(input);
View Full Code Here

    Kryo kryo = new Kryo();
    kryo.register(HashMap.class, new MapSerializer());
    kryo.register(ConcurrentHashMap.class, new MapSerializer());

    Output output = new Output(2048, -1);
    kryo.writeClassAndObject(output, map);
    output.close();

    Input input = new Input(output.toBytes());
    Object deserialized = kryo.readClassAndObject(input);
    input.close();

    Assert.assertEquals(map, deserialized);
  }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.io.Output

Copyright © 2018 www.massapicom. 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.