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

TagByte widthValue range
010–255
12256–65535
2465536–4294967295
384294967296–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.