CONST
CONST stores one integer and repeats it n times. It is codec id 0 in Flat and in IntCol, with the same layout in both.
Layout
Section titled “Layout”| Field | Encoding | Meaning |
|---|---|---|
| count | varint | n, the number of values |
| codec | u8 | 0 |
| v | zvarint | the value, see zvarint |
When n = 0 the writer stores v = 0.
How to decode
Section titled “How to decode”- Read
countand check it against its limit. - Read the codec byte. It is 0.
- Read
vas a zvarint. - The stream is
ncopies ofv.
Illustration
Section titled “Illustration”Derived by hand, not from a real file. Five copies of -3: zvarint of -3 is z = (-3 << 1) xor (-3 >> 63) = 5.
05 00 05 count 5, codec CONST, v = -3Decoded: -3, -3, -3, -3, -3.
Checks
Section titled “Checks”countis within its limit.- The zvarint is complete (a truncated or over-long varint is
Corrupt).
When writers pick it
Section titled “When writers pick it”See How writers choose a codec.