Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.UnsafeMemoryInput


    assertEquals(4, write.writeFloat(-65, 1000, false));
    assertEquals(4, write.writeFloat(-65, 1000, true));
    assertEquals(4, write.writeFloat(-8192, 1000, false));
    assertEquals(4, write.writeFloat(-8192, 1000, true));

    Input read = new UnsafeMemoryInput(write.toBytes());
    assertEquals(read.readFloat(), 0f);
    assertEquals(read.readFloat(), 63f);
    assertEquals(read.readFloat(), 64f);
    assertEquals(read.readFloat(), 127f);
    assertEquals(read.readFloat(), 128f);
    assertEquals(read.readFloat(), 8192f);
    assertEquals(read.readFloat(), 16384f);
    assertEquals(read.readFloat(), 32767f);
    assertEquals(read.readFloat(), -63f);
    assertEquals(read.readFloat(), -64f);
    assertEquals(read.readFloat(), -127f);
    assertEquals(read.readFloat(), -128f);
    assertEquals(read.readFloat(), -8192f);
    assertEquals(read.readFloat(), -16384f);
    assertEquals(read.readFloat(), -32768f);
    assertEquals(read.readFloat(1000, true), 0f);
    assertEquals(read.readFloat(1000, false), 0f);
    assertEquals(read.readFloat(1000, true), 63f);
    assertEquals(read.readFloat(1000, false), 63f);
    assertEquals(read.readFloat(1000, true), 64f);
    assertEquals(read.readFloat(1000, false), 64f);
    assertEquals(read.readFloat(1000, true), 127f);
    assertEquals(read.readFloat(1000, false), 127f);
    assertEquals(read.readFloat(1000, true), 128f);
    assertEquals(read.readFloat(1000, false), 128f);
    assertEquals(read.readFloat(1000, true), 8191f);
    assertEquals(read.readFloat(1000, false), 8191f);
    assertEquals(read.readFloat(1000, true), 8192f);
    assertEquals(read.readFloat(1000, false), 8192f);
    assertEquals(read.readFloat(1000, true), 16383f);
    assertEquals(read.readFloat(1000, false), 16383f);
    assertEquals(read.readFloat(1000, true), 16384f);
    assertEquals(read.readFloat(1000, false), 16384f);
    assertEquals(read.readFloat(1000, true), 32767f);
    assertEquals(read.readFloat(1000, false), 32767f);
    assertEquals(read.readFloat(1000, false), -64f);
    assertEquals(read.readFloat(1000, true), -64f);
    assertEquals(read.readFloat(1000, false), -65f);
    assertEquals(read.readFloat(1000, true), -65f);
    assertEquals(read.readFloat(1000, false), -8192f);
    assertEquals(read.readFloat(1000, true), -8192f);
  }
View Full Code Here


    assertEquals(8, write.writeDouble(-65, 1000, true));
    assertEquals(8, write.writeDouble(-8192, 1000, false));
    assertEquals(8, write.writeDouble(-8192, 1000, true));
    write.writeDouble(1.23456d);

    Input read = new UnsafeMemoryInput(write.toBytes());
    assertEquals(read.readDouble(), 0d);
    assertEquals(read.readDouble(), 63d);
    assertEquals(read.readDouble(), 64d);
    assertEquals(read.readDouble(), 127d);
    assertEquals(read.readDouble(), 128d);
    assertEquals(read.readDouble(), 8192d);
    assertEquals(read.readDouble(), 16384d);
    assertEquals(read.readDouble(), 32767d);
    assertEquals(read.readDouble(), -63d);
    assertEquals(read.readDouble(), -64d);
    assertEquals(read.readDouble(), -127d);
    assertEquals(read.readDouble(), -128d);
    assertEquals(read.readDouble(), -8192d);
    assertEquals(read.readDouble(), -16384d);
    assertEquals(read.readDouble(), -32768d);
    assertEquals(read.readDouble(1000, true), 0d);
    assertEquals(read.readDouble(1000, false), 0d);
    assertEquals(read.readDouble(1000, true), 63d);
    assertEquals(read.readDouble(1000, false), 63d);
    assertEquals(read.readDouble(1000, true), 64d);
    assertEquals(read.readDouble(1000, false), 64d);
    assertEquals(read.readDouble(1000, true), 127d);
    assertEquals(read.readDouble(1000, false), 127d);
    assertEquals(read.readDouble(1000, true), 128d);
    assertEquals(read.readDouble(1000, false), 128d);
    assertEquals(read.readDouble(1000, true), 8191d);
    assertEquals(read.readDouble(1000, false), 8191d);
    assertEquals(read.readDouble(1000, true), 8192d);
    assertEquals(read.readDouble(1000, false), 8192d);
    assertEquals(read.readDouble(1000, true), 16383d);
    assertEquals(read.readDouble(1000, false), 16383d);
    assertEquals(read.readDouble(1000, true), 16384d);
    assertEquals(read.readDouble(1000, false), 16384d);
    assertEquals(read.readDouble(1000, true), 32767d);
    assertEquals(read.readDouble(1000, false), 32767d);
    assertEquals(read.readDouble(1000, false), -64d);
    assertEquals(read.readDouble(1000, true), -64d);
    assertEquals(read.readDouble(1000, false), -65d);
    assertEquals(read.readDouble(1000, true), -65d);
    assertEquals(read.readDouble(1000, false), -8192d);
    assertEquals(read.readDouble(1000, true), -8192d);
    assertEquals(1.23456d, read.readDouble());
  }
View Full Code Here

    for (int i = 0; i < 100; i++) {
      write.writeBoolean(true);
      write.writeBoolean(false);
    }

    Input read = new UnsafeMemoryInput(write.toBytes());
    for (int i = 0; i < 100; i++) {
      assertEquals(true, read.readBoolean());
      assertEquals(false, read.readBoolean());
    }
  }
View Full Code Here

    write.writeChar((char)8192);
    write.writeChar((char)16384);
    write.writeChar((char)32767);
    write.writeChar((char)65535);

    Input read = new UnsafeMemoryInput(write.toBytes());
    assertEquals(0, read.readChar());
    assertEquals(63, read.readChar());
    assertEquals(64, read.readChar());
    assertEquals(127, read.readChar());
    assertEquals(128, read.readChar());
    assertEquals(8192, read.readChar());
    assertEquals(16384, read.readChar());
    assertEquals(32767, read.readChar());
    assertEquals(65535, read.readChar());
  }
View Full Code Here

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

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

      public Input createInput(byte[] buffer) {
        return new UnsafeMemoryInput(buffer);
      }
    });

    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
View Full Code Here

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

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

      public Input createInput(byte[] buffer) {
        return new UnsafeMemoryInput(buffer);
      }
    });

    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
View Full Code Here

                                              final Class<IN> type,
                                              final Consumer<IN> next) {
    return new Function<byte[], IN>() {
      @Override
      public IN apply(byte[] bytes) {
        IN obj = engine.readObject(new UnsafeMemoryInput(bytes), type);
        if(null != next) {
          next.accept(obj);
          return null;
        } else {
          return obj;
View Full Code Here

    final public void read (Input input, Object object) {
      if (bulkReadsSupported && input instanceof UnsafeInput) {
        UnsafeInput unsafeInput = (UnsafeInput)input;
        unsafeInput.readBytes(object, offset, len);
      } else if (bulkReadsSupported && input instanceof UnsafeMemoryInput) {
        UnsafeMemoryInput unsafeInput = (UnsafeMemoryInput)input;
        unsafeInput.readBytes(object, offset, len);
      } else {
        readSlow(input, object);
      }
    }
View Full Code Here

TOP

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

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.