Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.UnsafeOutput


  }

  // Check if writing varInts may produce more bytes than expected
  public void testWriteTooManyBytes () throws IOException {
    ByteArrayOutputStream os = new ByteArrayOutputStream(1);
    runVarIntTest(new UnsafeOutput(os, 4), os);
  }
View Full Code Here


    assertEquals(true, read.eof());
  }

  public void testSimpleVarInt() {
      final int value = 39117;
      final Output out = new UnsafeOutput(1024);
      out.writeVarInt(value, true);
      out.flush();
      final Input in = new UnsafeInput(out.toBytes());
      final int actualValue = in.readVarInt(true);
      assertEquals(value, actualValue);
  }
View Full Code Here

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

        Output kryoOut = null;

        kryoOut = new UnsafeOutput(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);
View Full Code Here

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

        Output kryoOut = null;

        kryoOut = new UnsafeOutput(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);
View Full Code Here

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

        Output kryoOut = null;

        kryoOut = new UnsafeOutput(out);

        marsh.writeObject(kryoOut, obj);
        kryoOut.close();
        // U.close(kryoOut, null);
View Full Code Here

      }
    });

    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
        return new UnsafeOutput(os);
      }

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

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

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

        cInfo.setHash(hash);

        log.debug("Serialising {} for {}", cInfo, className);

        // Serialise the ClassInfo object.
        @Cleanup UnsafeOutput serialisedOutput = new UnsafeOutput(INITIAL_BUFFER_SIZE);
        serialiser.writeObject(serialisedOutput, cInfo);

        byte[] buffer = serialisedOutput.toBytes();

        log.debug("Serialised using {} bytes", buffer.length);

        databaseMap.put(className, buffer);
        try {
View Full Code Here

      }
    });

    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
        return new UnsafeOutput(os);
      }

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

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

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

      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

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.