Skip to content

DELTA stores an integer stream as a few absolute values and the differences between neighbours. It is codec id 2 in IntCol only. It is not available in Flat.

Field Encoding Meaning
count varint n, the number of values. n >= 1 is required.
codec u8 2
samples Flat ceil(n/64) absolute values, at indices 0, 64, 128, …
deltas Flat n - 1 wrapping differences between neighbours

Each Flat here has its own count, codec byte and body, see Column container types.

  1. Read count (at least 1), the codec byte (2), the samples Flat and the deltas Flat.
  2. Value 0 is sample 0.
  3. For i from 1, value i is value i - 1 plus deltas[i - 1], with 64-bit wrapping arithmetic.
  4. The sample at index 64 k is the absolute value of the stream at that index, so a reader can start from the nearest earlier sample instead of from index 0.

Derived by hand, not from a real file. The values 10, 13, 16, 19 give one sample (ceil(4/64) = 1) of 10 and the 3 deltas 3, 3, 3.

04 02 count 4, codec DELTA
01 00 14 samples: Flat, count 1, CONST, v = 10
03 00 06 deltas: Flat, count 3, CONST, v = 3

Decoded: 10, 13, 16, 19.

  • n >= 1.
  • The samples Flat has ceil(n/64) values and the deltas Flat has n - 1.
  • The arithmetic wraps; it does not fail on overflow.

See How writers choose a codec.