U64Coder1248
U64Coder1248 stores u64 values using 1, 2, 4, or 8 bytes. It covers the full u64 range without truncation.
Wire-compatible with streamvbyte64::Coder1248.
Tag table
| Tag | Byte width | Value range |
|---|---|---|
| 0 | 1 | 0–255 |
| 1 | 2 | 256–65535 |
| 2 | 4 | 65536–4294967295 |
| 3 | 8 | 4294967296–18446744073709551615 |
Note there is no 3-byte option. Values in the range 65536–16777215 require 4 bytes.
Example
#![allow(unused)] fn main() { use svb::u64::U64Coder1248; let values: Vec<u64> = vec![1, 500, 1 << 32, u64::MAX]; let encoded = U64Coder1248.encode(&values); let decoded = U64Coder1248.decode(&encoded, values.len()).unwrap(); assert_eq!(decoded, values); }
When to use
Use U64Coder1248 when values may exceed u32::MAX. If all values fit within 32 bits, U64Coder1234 gives better compression because it can use 3 bytes for values in the 65536–16777215 range.