Skip to content

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.

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.

  1. Read the lens IntCol. Its count is n.
  2. Read the offset samples Flat, then total, then total bytes.
  3. The offset of value i is the sample at index i div 64 plus the sum of the lengths of the values from index 64 x (i div 64) up to i - 1.
  4. Value i is the lens[i] bytes at that offset.

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 PLAIN
03 01 00 02 32 lens: IntCol, count 3, FOR, min 0, width 2, lengths 2 0 3
01 00 00 offset samples: Flat, count 1, CONST 0
05 total 5
61 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.

  • The offset samples Flat has ceil(n/64) entries.
  • Each value lies inside the total bytes (checked arithmetic). Readers do not require the lengths to add up to exactly total.
  • total is at most the length of the block.

See How writers choose a codec.