/** The raw size of the underlying `Put'. */ int predictPutSize() { int size = 0; size += 1; // byte: Type of the 2nd parameter. size += 1; // byte: Type again (see HBASE-2877). size += 1; // byte: Version of Put. size += 3; // vint: row key length (3 bytes => max length = 32768). size += key.length; // The row key. size += 8; // long: Timestamp. size += 8; // long: Lock ID. size += 1; // bool: Whether or not to write to the WAL. size += 4; // int: Number of families for which we have edits. size += 1; // vint: Family length (guaranteed on 1 byte). size += family.length; // The family. size += 4; // int: Number of KeyValues that follow. size += 4; // int: Total number of bytes for all those KeyValues. size += payloadSize(); return size; }
/** Serialize the raw underlying `Put' into the given buffer. */ void serializeInto(final ChannelBuffer buf) { buf.writeByte(CODE); // Code for a `Put' parameter. buf.writeByte(CODE); // Code again (see HBASE-2877). buf.writeByte(1); // Put#PUT_VERSION. Stick to v1 here for now. writeByteArray(buf, key); // The row key. buf.writeLong(timestamp); // Timestamp. buf.writeLong(lockid); // Lock ID. buf.writeByte(durable ? 0x01 : 0x00); // Whether or not to use the WAL. buf.writeInt(1); // Number of families that follow. writeByteArray(buf, family); // The column family. buf.writeInt(qualifiers.length); // Number of "KeyValues" that follow. buf.writeInt(payloadSize()); // Size of the KV that follows. serializePayload(buf); }