Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.UnsafeMemoryOutput


    assertEquals(-16384, read.readShort());
    assertEquals(-32768, read.readShort());
  }

  public void testFloats () throws IOException {
    runFloatTest(new UnsafeMemoryOutput(4096));
    runFloatTest(new UnsafeMemoryOutput(new ByteArrayOutputStream()));
  }
View Full Code Here


    assertEquals(read.readFloat(1000, false), -8192f);
    assertEquals(read.readFloat(1000, true), -8192f);
  }

  public void testDoubles () throws IOException {
    runDoubleTest(new UnsafeMemoryOutput(4096));
    runDoubleTest(new UnsafeMemoryOutput(new ByteArrayOutputStream()));
  }
View Full Code Here

    assertEquals(read.readDouble(1000, true), -8192d);
    assertEquals(1.23456d, read.readDouble());
  }

  public void testBooleans () throws IOException {
    runBooleanTest(new UnsafeMemoryOutput(4096));
    runBooleanTest(new UnsafeMemoryOutput(new ByteArrayOutputStream()));
  }
View Full Code Here

      assertEquals(false, read.readBoolean());
    }
  }

  public void testChars () throws IOException {
    runCharTest(new UnsafeMemoryOutput(4096));
    runCharTest(new UnsafeMemoryOutput(new ByteArrayOutputStream()));
  }
View Full Code Here

  public <T> T roundTrip(int length, int unsafeLength, T object1) {
   
    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
        return new UnsafeMemoryOutput(os);
      }

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

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

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

  public <T> T roundTrip(int length, int unsafeLength, T object1) {
   
    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
        return new UnsafeMemoryOutput(os);
      }

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

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

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

  @Override
  protected Function<OUT, byte[]> serializer(final Kryo engine) {
    return new Function<OUT, byte[]>() {
      @Override
      public byte[] apply(OUT o) {
        UnsafeMemoryOutput out = new UnsafeMemoryOutput(Buffer.SMALL_BUFFER_SIZE, Buffer.MAX_BUFFER_SIZE);
        engine.writeObject(out, o);
        out.flush();
        return out.toBytes();
      }
    };
  }
View Full Code Here

    final public void write (Output output, Object object) {
      if (output instanceof UnsafeOutput) {
        UnsafeOutput unsafeOutput = (UnsafeOutput)output;
        unsafeOutput.writeBytes(object, offset, len);
      } else if (output instanceof UnsafeMemoryOutput) {
        UnsafeMemoryOutput unsafeOutput = (UnsafeMemoryOutput)output;
        unsafeOutput.writeBytes(object, offset, len);
      } else {
        long off;
        Unsafe unsafe = unsafe();
        for (off = offset; off < offset + len - 8; off += 8) {
          output.writeLong(unsafe.getLong(object, off));
View Full Code Here

TOP

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

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.