VByte
VByte (variable byte) is a scheme that encodes a non-negative integer as variable-length bytes: each byte carries 7 bits of payload, with the most significant bit as the continuation flag.
Purpose
It stores and transports integer sequences compactly when small values dominate, such as document ID gaps in inverted indexes.
Mechanism
The integer's 7-bit groups are written from low to high; a byte's highest bit is 0 for the final byte and 1 when more follow. Small integers (< 128) need only 1 byte, and larger values extend as needed.
Use cases
- Document ID encoding in inverted indexes
- Variable-length integer fields in databases
- Variable-length lengths in protocol headers