The Mutation class supports two serialization formats. While it only currently serializes to the newer version 2 format, it can read both version 1 and version 2 serialized forms.

Version 1 Format

Mutation data serialized in the version 1 format has the following layout.

data location description
bytes 0 through 3 4-byte integer for length of row ID
next n bytes row ID
next integer data length
next n bytes data (see below)
next integer number of entries
next boolean values present flag
next integer number of values (only if values present flag is set)
next n sets of integers and byte arrays n value lengths and value data bytes (only if values present flag is set)

The "data" block noted above has the following layout for each entry.

first integer and byte array column family length and bytes
next integer and byte array column qualifier length and bytes
next integer and byte array column visibility length and bytes
next boolean has timestamp flag
next long timestamp
next boolean deleted flag
next integer value length; if negative, value bytes are the same as those for already-read value (-length - 1)
next n bytes value bytes (only if value length is non-negative)

Version 2 Format

Mutation data serialized in the version 2 format has the following layout. This format uses variable length encoding for integers and longs.

data location description
byte 0 control byte: top bit = 1 for version 2; bottom bit = values present flag
next integer length of row ID
next n bytes row ID
next integer data length
next n bytes data (see below)
next integer number of entries
next integer number of values (only if values present flag is set)
next n sets of integers and byte arrays n value lengths and value data bytes (only if values present flag is set)

The "data" block noted above has the following layout for each entry.

first long and byte array column family length and bytes
next long and byte array column qualifier length and bytes
next long and byte array column visibility length and bytes
next boolean has timestamp flag
next long timestamp (only present if timestamp flag is set)
next boolean deleted flag
next long value length; if negative, value bytes are the same as those for already-read value (-length - 1)
next n bytes value bytes (only if value length is non-negative)