Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.ByteBufferInput


    long bufAddress = UnsafeUtil.unsafe().allocateMemory(4096);
    try {
      ByteBufferOutput outputBuffer = new ByteBufferOutput(bufAddress, 4096);
      outputBuffer.writeInt(10);

      ByteBufferInput inputBuffer = new ByteBufferInput(outputBuffer.getByteBuffer());
      inputBuffer.readInt();
      inputBuffer.release();

      outputBuffer.release();
      outputBuffer = new UnsafeMemoryOutput(bufAddress, 4096);
      outputBuffer.writeInt(10);

      inputBuffer = new UnsafeMemoryInput(outputBuffer.getByteBuffer());
      inputBuffer.readInt();
      inputBuffer.release();
      outputBuffer.release();
    } catch (Throwable t) {
      System.err.println("Streams with preallocated direct memory are not supported on this JVM");
      t.printStackTrace();
    } finally {
View Full Code Here


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

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

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

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

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

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

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

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

  public <T extends Entry> void testSerializeAndDeserializeEntry(Class<T> entryType, T entry)
    throws Exception {
    Kryo kryo = new Kryo();
    ByteBuffer buffer = ByteBuffer.allocate(4096);
    Output output = new ByteBufferOutput(buffer);
    Input input = new ByteBufferInput(buffer);
    Class<? extends Serializer> serializer = entryType.getAnnotation(EntryType.class).serializer();
    kryo.register(entryType, serializer.newInstance(), entryType.getAnnotation(EntryType.class) .id());
    kryo.writeClassAndObject(output, entry);
    T result = (T) kryo.readClassAndObject(input);
    Assert.assertEquals(entry, result);
View Full Code Here

    kryo.register(RegisterUDP.class);
    kryo.register(KeepAlive.class);
    kryo.register(DiscoverHost.class);
    kryo.register(Ping.class);

    input = new ByteBufferInput();
    output = new ByteBufferOutput();
  }
View Full Code Here

TOP

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

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.