Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.UnsafeOutput


      this.len = len;
    }

    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


    return (isUnsafe)? new UnsafeInput(inputStream, bufferSize) : new Input(inputStream, bufferSize);
  }

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

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

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

    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

/** @author Nathan Sweet <misc@n4te.com> */
public class UnsafeInputOutputTest extends KryoTestCase {
  public void testOutputStream () throws IOException {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    UnsafeOutput output = new UnsafeOutput(buffer, 2);
    output.writeBytes(new byte[] {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26});
    output.writeBytes(new byte[] {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46});
    output.writeBytes(new byte[] {51, 52, 53, 54, 55, 56, 57, 58});
    output.writeBytes(new byte[] {61, 62, 63, 64, 65});
    output.flush();

    assertEquals(new byte[] { //
      11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, //
        31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, //
        51, 52, 53, 54, 55, 56, 57, 58, //
View Full Code Here

    System.arraycopy(temp, 512, temp2, 0, count);
    assertEquals(bytes, temp2);
  }

  public void testWriteBytes () throws IOException {
    UnsafeOutput buffer = new UnsafeOutput(512);
    buffer.writeBytes(new byte[] {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26});
    buffer.writeBytes(new byte[] {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46});
    buffer.writeByte(51);
    buffer.writeBytes(new byte[] {52, 53, 54, 55, 56, 57, 58});
    buffer.writeByte(61);
    buffer.writeByte(62);
    buffer.writeByte(63);
    buffer.writeByte(64);
    buffer.writeByte(65);
    buffer.flush();

    assertEquals(new byte[] { //
      11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, //
        31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, //
        51, 52, 53, 54, 55, 56, 57, 58, //
        61, 62, 63, 64, 65}, buffer.toBytes());
  }
View Full Code Here

TOP

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

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.