Expand description
Variable-length integer encoding.
Unsigned integers use LEB128 — little-endian base 128. Each byte carries 7 data bits; the high bit is 1 while more bytes follow and 0 on the last byte. Values 0..127 fit in one byte.
Signed integers use ZigZag mapping (positive and negative interleaved into the unsigned range) and are then LEB128-encoded. Small positive values like rowid=1 take one byte; small negative values do too.
These are the encodings used for lengths, column counts, rowids, and
Integer cell values. Fixed-width encodings stay in place for tags (u8)
and Real values (f64, 8 bytes).
Constants§
- MAX_
VARINT_ BYTES - Upper bound on bytes for a 64-bit LEB128 value:
ceil(64 / 7) = 10.
Functions§
- i64_len
- Same as
u64_lenfor a zigzagged signedi64. - read_
i64 - Reads a ZigZag-encoded signed
i64(LEB128). Returns(value, bytes_consumed). - read_
u64 - Reads a LEB128
u64frombufstarting atpos. Returns(value, bytes_consumed). - u64_len
- Returns the number of bytes
write_u64(value)would produce, without writing. - write_
i64 - Writes a ZigZag-encoded signed
i64as LEB128. Returns bytes written. - write_
u64 - Appends a LEB128-encoded
u64toout. Returns the number of bytes written.