Bytes PLAIN
PLAIN stores byte strings back to back with a table of their lengths. It is codec id 0 in BytesCol. The same layout, called Plain, is also the building block inside Bytes DICT, FRONT and FSST.
Layout
Section titled “Layout”| Field | Encoding | Meaning |
|---|---|---|
| codec | u8 | 0 (only for a BytesCol; a bare Plain has no codec byte) |
| lens | IntCol | the length of each value, n entries |
| offset samples | Flat | ceil(n/64) entries: the offset of every 64th value |
| total | varint (count) | total number of data bytes |
| bytes | total bytes |
all values concatenated |
Each IntCol and Flat has its own count, codec byte and body, see Column container types.
How to decode
Section titled “How to decode”- Read the lens IntCol. Its count is
n. - Read the offset samples Flat, then
total, thentotalbytes. - The offset of value
iis the sample at indexi div 64plus the sum of the lengths of the values from index64 x (i div 64)up toi - 1. - Value
iis thelens[i]bytes at that offset.
Illustration
Section titled “Illustration”Derived by hand, not from a real file. The three values ab, an empty string, and cde have lengths 2, 0, 3. One offset sample (ceil(3/64) = 1), value 0.
00 codec PLAIN03 01 00 02 32 lens: IntCol, count 3, FOR, min 0, width 2, lengths 2 0 301 00 00 offset samples: Flat, count 1, CONST 005 total 561 62 63 64 65 "ab" "" "cde"Offsets: value 0 at 0, value 1 at 2, value 2 at 2 (length 0 before it). Value 2 is bytes 2 to 4, cde.
Checks
Section titled “Checks”- The offset samples Flat has
ceil(n/64)entries. - Each value lies inside the
totalbytes (checked arithmetic). Readers do not require the lengths to add up to exactlytotal. totalis at most the length of the block.
When writers pick it
Section titled “When writers pick it”See How writers choose a codec.