Skip to main content

Crate svb

Crate svb 

Source
Expand description

Pure-Rust StreamVByte covering u16, u32, and u64 integer codecs with optional SIMD acceleration.

§Codec variants

TypeStructTagByte widthsNotes
u16u16::Svb161-bit1/2ONT VBZ format
u32u32::U32Classic2-bit1/2/3/4Lemire reference-compatible
u32u32::U32Variant01242-bit0/1/2/4Sparse-data variant
u64u64::U64Coder12342-bit1/2/3/4Values must fit in u32
u64u64::U64Coder12482-bit1/2/4/8Full u64 range

Delta and zigzag transforms are composable layers in delta and zigzag.

§Feature flags

Enable simd-auto for runtime CPU detection (recommended). Use simd-avx2, simd-ssse3, or simd-neon for compile-time SIMD when the target is known. Disable std and enable alloc for no_std use; all codec functionality requires at least the alloc feature.

no_std note: simd-auto on x86-64 requires std for is_x86_feature_detected!. When std is disabled, simd-auto compiles but silently falls back to scalar regardless of the CPU’s actual capabilities. Use simd-avx2 or simd-ssse3 with a compile-time target-feature flag (RUSTFLAGS="-C target-feature=+avx2") for SIMD in no_std builds.

Re-exports§

pub use error::DecodeError;

Modules§

delta
Delta encoding and decoding as a composable layer over any integer type.
error
u16
StreamVByte codec for u16 values using 1-bit control tags.
u32
StreamVByte codecs for u32 values using 2-bit control tags.
u64
StreamVByte codecs for u64 values using 2-bit control tags.
zigzag
Zigzag encoding and decoding as a composable layer over signed integer types.

Functions§

decode_vbz
Decode exactly n i16 samples from SVB16 bytes (after zstd decompression).
decode_vbz2Deprecated
Decode VBZ2-encoded data (format produced by encode_vbz2).
decode_vbz2_intoDeprecated
Decode VBZ2-encoded data into an existing Vec (avoids allocation if capacity is sufficient).
decode_vbz_fused
Decode a VBZ-encoded byte stream into i16 samples using a fused single-pass decoder.
decode_vbz_fused_from
Decode a VBZ half-stream starting from an arbitrary initial_carry value.
decode_vbz_fused_from_into
Decode a VBZ half-stream starting from initial_carry, appending to out.
decode_vbz_fused_into
Decode a VBZ-encoded byte stream, appending to out. See decode_vbz_fused.
decode_vbz_into
Decode exactly n i16 samples from SVB16 bytes, appending them to out.
decode_vbzk
Decode VBZ-K encoded data, returning a new Vec<i16>.
decode_vbzk_into
Decode VBZ-K encoded data sequentially (one sub-stream at a time), appending to out.
decode_vbzk_parallel
Decode VBZ-K encoded data in parallel using k threads, returning a new Vec<i16>.
decode_vbzk_parallel_into
Decode VBZ-K encoded data in parallel using k threads, appending to out.
encode_vbz
Encode i16 samples through delta, zigzag, then SVB16, returning raw bytes ready to pass to zstd.
encode_vbz2Deprecated
Encode samples to VBZ2 format (standard VBZ with a 6-byte header enabling 2-chain decode).
encode_vbz_into
Encode i16 samples through delta, zigzag, then SVB16, appending the result to out.
encode_vbzk
Encode samples to VBZ-K format — k independent sub-streams decodable in parallel.