Skip to content

Instantly share code, notes, and snippets.

@rustyrazorblade
Last active September 11, 2015 18:57
Show Gist options
  • Save rustyrazorblade/cb42d4aee0449233b463 to your computer and use it in GitHub Desktop.
Save rustyrazorblade/cb42d4aee0449233b463 to your computer and use it in GitHub Desktop.
cassandra storage format notes
# https://github.com/apache/cassandra/blob/cassandra-3.0/src/java/org/apache/cassandra/io/sstable/format/big/BigTableWriter.java#L135
# UnfilteredRowIteratorSerializer
https://github.com/apache/cassandra/blob/cassandra-3.0/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java#L34-34
Partition Header: <key><flags><s_header>[<partition_deletion>][<static_row>][<row_estimate>]
Then the rows
https://github.com/apache/cassandra/blob/cassandra-3.0/src/java/org/apache/cassandra/db/rows/BufferCell.java#L200-200
/**
* The serialization format for cell is:
* [ flags ][ timestamp ][ deletion time ][ ttl ][ path size ][ path ][ value size ][ value ]
* [ 1b ][ 8b (vint) ][ 4b (vint) ][ 4b (vint) ][ 4b (vint) ][ arb ][ 4b (vint) ][ arb ]
*
* where not all field are always present (in fact, only the [ flags ] are guaranteed to be present). The fields have the following
* meaning:
* - [ flags ] is the cell flags. It is a byte for which each bit represents a flag whose meaning is explained below (*_MASK constants)
* - [ timestamp ] is the cell timestamp. Present unless the cell has the USE_TIMESTAMP_MASK.
* - [ deletion time]: the local deletion time for the cell. Present if either the cell is deleted (IS_DELETED_MASK)
* or it is expiring (IS_EXPIRING_MASK) but doesn't have the USE_ROW_TTL_MASK.
* - [ ttl ]: the ttl for the cell. Present if the row is expiring (IS_EXPIRING_MASK) but doesn't have the
* USE_ROW_TTL_MASK.
* - [ value size ] is the size of the [ value ] field. It's present unless either the cell has the HAS_EMPTY_VALUE_MASK, or the value
* for columns of this type have a fixed length.
* - [ path size ] is the size of the [ path ] field. Present iff this is the cell of a complex column.
* - [ value ]: the cell value, unless it has the HAS_EMPTY_VALUE_MASK.
* - [ path ]: the cell path if the column this is a cell of is complex.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment