Package com.esotericsoftware.kryo.io

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


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

    write.writeInt(400, true);

    read = new Input(write.toBytes());
    assertEquals(true, read.canReadInt());
    read.setLimit(read.limit() - 1);
    assertEquals(false, read.canReadInt());
  }
View Full Code Here


          for (int i = 0; i < 16; i++) {
                out2.writeVarInt(92, false);
          }
         
          assertEquals(out1.toBytes(), out2.toBytes());
  }
 
  public void testZeroLengthOutputs() throws Exception {
    Output output = new Output(0, 10000);
    kryo.writeClassAndObject(output, "Test string");
View Full Code Here

    Output output = new Output(2048, -1);
    kryo.writeClassAndObject(output, map);
    output.close();

    Input input = new Input(output.toBytes());
    Object deserialized = kryo.readClassAndObject(input);
    input.close();

    Assert.assertEquals(map, deserialized);
  }
View Full Code Here

  public String toKryo() {
    Output out = new Output(4 * 1024, 10 * 1024 * 1024);
    new Kryo().writeObject(out, this);
    out.close();
    return Base64.encodeBase64String(out.toBytes());
  }

  static SearchArgument fromKryo(String value) {
    Input input = new Input(Base64.decodeBase64(value));
    return new Kryo().readObject(input, SearchArgumentImpl.class);
View Full Code Here

  public String toKryo() {
    Output out = new Output(4 * 1024, 10 * 1024 * 1024);
    new Kryo().writeObject(out, this);
    out.close();
    return Base64.encodeBase64String(out.toBytes());
  }

  static SearchArgument fromKryo(String value) {
    Input input = new Input(Base64.decodeBase64(value));
    return new Kryo().readObject(input, SearchArgumentImpl.class);
View Full Code Here

    @Override
    public byte[] write(Object object) {
        final Output output = new KryoObjectOutputStream(512, -1);
        kryo.writeClassAndObject(output, object);
        output.flush();
        return output.toBytes();
    }

    @Override
    public Object read(byte[] buf) {
        final Input input = new KryoObjectInputStream(buf);
View Full Code Here

  public String toKryo() {
    Output out = new Output(4 * 1024, 10 * 1024 * 1024);
    new Kryo().writeObject(out, this);
    out.close();
    return Base64.encodeBase64String(out.toBytes());
  }

  static SearchArgument fromKryo(String value) {
    Input input = new Input(Base64.decodeBase64(value));
    return new Kryo().readObject(input, SearchArgumentImpl.class);
View Full Code Here

    public byte[] write(Object object) {
        final Output out = getOutput();
        out.clear();
        kryo.writeClassAndObject(out, object);
        out.flush();
        return out.toBytes();
    }

    @Override
    public Object read(byte[] buf) {
        return read(buf, 0);
View Full Code Here

  {
    LOG.debug("Going to serialize: '{}'", object);
    Output buffer = getBuffer(object);
    try {
      getKryo().writeClassAndObject(buffer, object);
      byte[] data = buffer.toBytes();
      if (data == null)
      {
        LOG.error("Kryo wasn't able to serialize: '{}'", object);
      }
View Full Code Here

    @Override
    public ByteBuffer serialize(Object message) {
        Output output = outputThreadLocal.get();
        try {
            kryoThreadLocal.get().writeClassAndObject(output, message);
            return ByteBuffer.wrap(output.toBytes());
        } finally {
            output.clear();
        }
    }
}
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.