FRONT
FRONT stores each value as the number of leading bytes it shares with the previous value, plus its remaining suffix. It suits sorted or similar strings. It is codec id 2 in BytesCol.
Layout
Section titled “Layout”| Field | Encoding | Meaning |
|---|---|---|
| codec | u8 | 2 |
| shared | IntCol | shared-prefix length of each value with the previous one |
| suffixes | Plain | the suffix of each value, laid out as in Bytes PLAIN without its codec byte |
The shared length is 0 at every 16th value (indexes 0, 16, 32, …). Those values are stored whole, so a reader can start decoding at any such index.
How to decode
Section titled “How to decode”- Read the codec byte (2), the shared IntCol and the suffixes
Plain. - Value
iis the firstshared[i]bytes of valuei - 1, followed by suffixi. - Value 0, and every 16th value, has
shared = 0and so equals its suffix.
Illustration
Section titled “Illustration”Derived by hand, not from a real file. The values car, cart, cat have shared lengths 0, 3, 2 and suffixes car, t, t.
02 codec FRONT03 01 00 02 2C shared: IntCol, count 3, FOR, min 0, width 2, 0 3 203 01 02 02 02 suffix lens: IntCol, count 3, FOR, min 1, width 2, 3 1 101 00 00 offset samples: Flat, count 1, CONST 005 total 563 61 72 74 74 "car" "t" "t"Decoded: car; car first 3 bytes + t = cart; cart first 2 bytes ca + t = cat.
Checks
Section titled “Checks”- Each shared length is at most the length of the previous value.
- The suffix
Plainpasses the checks of Bytes PLAIN.
When writers pick it
Section titled “When writers pick it”See How writers choose a codec.