Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.Output


    return (isUnsafe)? new UnsafeOutput(bufferSize) : new Output(bufferSize);
  }

  @Override
  public Output getOutput(int bufferSize, int maxBufferSize) {
    return (isUnsafe)? new UnsafeOutput(bufferSize, maxBufferSize) : new Output(bufferSize, maxBufferSize);
  }
View Full Code Here


    return (isUnsafe)? new UnsafeOutput(bufferSize, maxBufferSize) : new Output(bufferSize, maxBufferSize);
  }

  @Override
  public Output getOutput(byte[] buffer) {
    return (isUnsafe)? new UnsafeOutput(buffer) : new Output(buffer);
  }
View Full Code Here

    return (isUnsafe)? new UnsafeOutput(buffer) : new Output(buffer);
  }

  @Override
  public Output getOutput(byte[] buffer, int maxBufferSize) {
    return (isUnsafe)? new UnsafeOutput(buffer, maxBufferSize) : new Output(buffer, maxBufferSize);
  }
View Full Code Here

    return (isUnsafe)? new UnsafeOutput(buffer, maxBufferSize) : new Output(buffer, maxBufferSize);
  }

  @Override
  public Output getOutput(OutputStream outputStream) {
    return (isUnsafe)? new UnsafeOutput(outputStream) : new Output(outputStream);
  }
View Full Code Here

    return (isUnsafe)? new UnsafeOutput(outputStream) : new Output(outputStream);
  }

  @Override
  public Output getOutput(OutputStream outputStream, int bufferSize) {
    return (isUnsafe)? new UnsafeOutput(outputStream, bufferSize) : new Output(outputStream, bufferSize);
  }
View Full Code Here

  }

  public void write (Kryo kryo, Output output, Object object) {
    Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
    CipherOutputStream cipherStream = new CipherOutputStream(output, cipher);
    Output cipherOutput = new Output(cipherStream, 256) {
      public void close () throws KryoException {
        // Don't allow the CipherOutputStream to close the output.
      }
    };
    kryo.writeObject(cipherOutput, object, serializer);
    cipherOutput.flush();
    try {
      cipherStream.close();
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
View Full Code Here

        Ordering ordering = kryo.readObjectOrNull(input, Ordering.class);
        return new Stuff(ordering);
      }
    });

    Output output = new Output(512, -1);
    kryo.writeObject(output, stuff);

    Input input = new Input(output.getBuffer(), 0, output.position());
    Stuff stuff2 = kryo.readObject(input, Stuff.class);

    assertEquals(stuff.ordering.order, stuff2.ordering.order);
    assertEquals(stuff.get("key"), stuff2.get("key"));
    assertEquals(stuff.get("something"), stuff2.get("something"));
View Full Code Here

import com.esotericsoftware.kryo.io.OutputChunked;

/** @author Nathan Sweet <misc@n4te.com> */
public class ChunkedTest extends KryoTestCase {
  public void testChunks () {
    Output output = new Output(512);
    output.writeInt(1234);
    OutputChunked outputChunked = new OutputChunked(output);
    outputChunked.writeInt(1);
    outputChunked.endChunks();
    outputChunked.writeInt(2);
    outputChunked.endChunks();
    outputChunked.writeInt(3);
    outputChunked.endChunks();
    outputChunked.writeInt(4);
    outputChunked.endChunks();
    outputChunked.writeInt(5);
    outputChunked.endChunks();
    output.writeInt(5678);
    output.close();

    Input input = new Input(output.getBuffer());
    assertEquals(1234, input.readInt());
    InputChunked inputChunked = new InputChunked(input);
    assertEquals(1, inputChunked.readInt());
    inputChunked.nextChunks();
    inputChunked.nextChunks(); // skip 3
View Full Code Here

      long start = System.nanoTime();

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

        Output kryoOut = null;

        try {
          kryoOut = new Output(out);
          marsh.writeObject(kryoOut, obj);
        } finally {
          kryoOut.close();
          // U.close(kryoOut, null);
        }

        Input kryoIn = null;

        try {
          kryoIn = new Input(kryoOut.getBuffer(), 0, kryoOut.position());
          newObj = marsh.readObject(kryoIn, SampleObject.class);
        } finally {
          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;

        try {
          kryoOut = new Output(OUTPUT_BUFFER_SIZE);

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

        Input kryoIn = null;

        try {
          kryoIn = new Input(kryoOut.getBuffer(), 0, kryoOut.position());
          newObj = marsh.readObject(kryoIn, SampleObject.class);
        } finally {
          // U.close(kryoIn, null);
          kryoIn.close();
        }
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.