Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.Output.toBytes()


                final long size = output.total();
                if (size > Integer.MAX_VALUE)
                    throw new SerializationException(String.format("Message size of %s exceeds allocatable space", size));

                encodedMessage = allocator.buffer((int) output.total());
                encodedMessage.writeBytes(output.toBytes());
            }

            return encodedMessage;
        } catch (Exception ex) {
            if (encodedMessage != null) ReferenceCountUtil.release(encodedMessage);
View Full Code Here


                final long size = output.total();
                if (size > Integer.MAX_VALUE)
                    throw new SerializationException(String.format("Message size of %s exceeds allocatable space", size));

                encodedMessage = allocator.buffer((int) size);
                encodedMessage.writeBytes(output.toBytes());
            }

            return encodedMessage;
        } catch (Exception ex) {
            if (encodedMessage != null) ReferenceCountUtil.release(encodedMessage);
View Full Code Here

        try {
            this.headerWriter.write(createKryo(), out);
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
        this.versionedHeader = out.toBytes();
    }

    public Kryo createKryo() {
        final Kryo kryo = new Kryo(new GremlinClassResolver(), new MapReferenceResolver(), new DefaultStreamFactory());
        kryo.addDefaultSerializer(Map.Entry.class, new EntrySerializer());
View Full Code Here

    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());
  }

  public void testStrings () throws IOException {
    runStringTest(new Output(4096));
    runStringTest(new Output(897));
View Full Code Here

    runStringTest(new Output(new ByteArrayOutputStream()));

    Output write = new Output(21);
    String value = "abcdef\u00E1\u00E9\u00ED\u00F3\u00FA\u1234";
    write.writeString(value);
    Input read = new Input(write.toBytes());
    assertEquals(value, read.readString());

    write.clear();
    write.writeString(null);
    read = new Input(write.toBytes());
View Full Code Here

    Input read = new Input(write.toBytes());
    assertEquals(value, read.readString());

    write.clear();
    write.writeString(null);
    read = new Input(write.toBytes());
    assertEquals(null, read.readString());

    for (int i = 0; i <= 258; i++)
      runStringTest(i);
    runStringTest(1);
View Full Code Here

      buffer.append((char)i);

    String value = buffer.toString();
    write.writeString(value);
    write.writeString(value);
    Input read = new Input(write.toBytes());
    assertEquals(value, read.readString());
    assertEquals(value, read.readStringBuilder().toString());

    write.clear();
    write.writeString(buffer);
View Full Code Here

    assertEquals(value, read.readStringBuilder().toString());

    write.clear();
    write.writeString(buffer);
    write.writeString(buffer);
    read = new Input(write.toBytes());
    assertEquals(value, read.readStringBuilder().toString());
    assertEquals(value, read.readString());

    if (length <= 127) {
      write.clear();
View Full Code Here

    if (length <= 127) {
      write.clear();
      write.writeAscii(value);
      write.writeAscii(value);
      read = new Input(write.toBytes());
      assertEquals(value, read.readStringBuilder().toString());
      assertEquals(value, read.readString());
    }
  }
View Full Code Here

  }

  public void testCanReadInt () throws IOException {
    Output write = new Output(new ByteArrayOutputStream());

    Input read = new Input(write.toBytes());
    assertEquals(false, read.canReadInt());

    write.writeInt(400, true);

    read = new Input(write.toBytes());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.