...
Given a set of user-defined columns, this set is then rearranged so that fixed-sized columns go first. This sorted set of columns is used to form a row. Row layout is as follows:
Field | Size |
---|---|
Schema version | 2 bytes |
Key columns hash | 4 bytes |
Key chunk: | |
Key chunk size | 4 bytes |
Flags | 1 byte |
Variable-length columns offsets table size | 2 bytes |
Variable-length columns offsets table | Variable (number of non-null varlen columns * 4) |
Fix-sized columns values | Variable |
Variable-length columns values | Variable |
Value chunk: | |
Value chunk size | 4 bytes |
Flags | 1 byte |
Null-map |
(number of columns / 8 |
) - If the value columns contains nullable column:0 bytes - otherwise | |
Variable-length columns offsets table size | 2 bytes |
Variable-length columns offsets table | Variable (number of non-null varlen columns * 4) |
Fix-sized columns values | Variable |
Variable-length columns values | Variable |
For the small rows, the metadata sizes may introduce a very noticeable overhead, so it looks reasonable to write them in a more compact way using different techniques.
...
The flags field is a bitmask with each bit treated as a flag, with the following flags available (from flag 0 being the LSB to flag 7 being MSB):
Flags Bits | Description |
---|
...
0 |
...
, 1 | VarTable formats:
|
2-7 | Reserverd |
...
...