@Override public byte[] apply(OUT o) { UnsafeMemoryOutput out = new UnsafeMemoryOutput(Buffer.SMALL_BUFFER_SIZE, Buffer.MAX_BUFFER_SIZE); engine.writeObject(out, o); out.flush(); return out.toBytes(); } };
writeByte((byte)varInt); return 1; writeLittleEndianInt((int)varInt); position -= 2; return 2; writeLittleEndianInt((int)varInt); position -= 1; return 3; writeLittleEndianInt((int)varInt); position -= 0; return 4; varInt |= ((value & 0x7F) << 32); varInt &= 0xFFFFFFFFFL; writeLittleEndianLong(varInt); position -= 3; return 5;
/*** Output count bytes from a memory region starting at the given #{offset} inside the in-memory representation of obj object. * @param obj * @param offset * @param count */ final public void writeBytes (Object obj, long offset, long count) throws KryoException { writeBytes(obj, byteArrayBaseOffset, offset, count); }
/** Writes an 8 byte long. */ final public void writeLong (long value) throws KryoException { require(8); unsafe().putLong(bufaddress + position, value); position += 8; }
/** Creates a new Output for writing to a byte array. * * @param bufferSize The initial size of the buffer. * @param maxBufferSize The buffer is doubled as needed until it exceeds maxBufferSize and an exception is thrown. */ public UnsafeMemoryOutput (int bufferSize, int maxBufferSize) { super(bufferSize, maxBufferSize); updateBufferAddress(); }
final public int writeInt (int value, boolean optimizePositive) throws KryoException { if (!varIntsEnabled) { writeInt(value); return 4; } else return writeVarInt(value, optimizePositive); }
write(varInt); return 1; writeLittleEndianInt(varInt); position -= 2; return 2; writeLittleEndianInt(varInt); position -= 1; return 3; writeLittleEndianInt(varInt); position -= 0; return 4; writeLittleEndianLong(varLong); position -= 3; return 5; writeLittleEndianLong(varLong); position -= 2; return 6; writeLittleEndianLong(varLong); position -= 1; return 7; writeLittleEndianLong(varLong); return 8;
writeByte((byte)varInt); return 1; writeLittleEndianInt((int)varInt); position -= 2; return 2; writeLittleEndianInt((int)varInt); position -= 1; return 3; writeLittleEndianInt((int)varInt); position -= 0; return 4; varInt |= ((value & 0x7F) << 32); varInt &= 0xFFFFFFFFFL; writeLittleEndianLong(varInt); position -= 3; return 5;
/*** Output count bytes from a memory region starting at the given #{offset} inside the in-memory representation of obj object. * @param obj * @param offset * @param count */ final public void writeBytes (Object obj, long offset, long count) throws KryoException { writeBytes(obj, 0, offset, count); }
/** Writes a 4 byte int. */ final public void writeInt (int value) throws KryoException { require(4); unsafe().putInt(bufaddress + position, value); position += 4; }
/** Creates a new Output for writing to an OutputStream. A buffer size of 4096 is used. */ public UnsafeMemoryOutput (OutputStream outputStream) { super(outputStream); updateBufferAddress(); }
final public int writeInt (int value, boolean optimizePositive) throws KryoException { if (!varIntsEnabled) { writeInt(value); return 4; } else return writeVarInt(value, optimizePositive); }
write(varInt); return 1; writeLittleEndianInt(varInt); position -= 2; return 2; writeLittleEndianInt(varInt); position -= 1; return 3; writeLittleEndianInt(varInt); position -= 0; return 4; writeLittleEndianLong(varLong); position -= 3; return 5; writeLittleEndianLong(varLong); position -= 2; return 6; writeLittleEndianLong(varLong); position -= 1; return 7; writeLittleEndianLong(varLong); return 8;
writeByte((byte)varInt); return 1; writeLittleEndianInt((int)varInt); position -= 2; return 2; writeLittleEndianInt((int)varInt); position -= 1; return 3; writeLittleEndianInt((int)varInt); position -= 0; return 4; varInt |= ((value & 0x7F) << 32); varInt &= 0xFFFFFFFFL; writeLittleEndianLong(varInt); position -= 3; return 5;
@Override public byte[] apply(OUT o) { final Kryo kryo = engine.borrow(); try { UnsafeMemoryOutput out = new UnsafeMemoryOutput(Buffer.SMALL_BUFFER_SIZE, Buffer.MAX_BUFFER_SIZE); kryo.writeObject(out, o); out.flush(); return out.toBytes(); } finally { engine.release(kryo); } } };
final public void writeInts (int[] object) throws KryoException { int bytesToCopy = object.length << 2; writeBytes(object, intArrayBaseOffset, 0, bytesToCopy); }
/** Writes a 4 byte int. */ final public void writeInt (int value) throws KryoException { require(4); unsafe().putInt(bufaddress + position, value); position += 4; }
/** Creates a new Output for writing to an OutputStream. */ public UnsafeMemoryOutput (OutputStream outputStream, int bufferSize) { super(outputStream, bufferSize); updateBufferAddress(); }