Expand description
Vortex’s BtrBlocks-inspired adaptive compression framework.
This crate provides a sophisticated multi-level compression system that adaptively selects optimal compression schemes based on data characteristics. The compressor analyzes arrays to determine the best encoding strategy, supporting cascaded compression with multiple encoding layers for maximum efficiency.
§Key Features
- Adaptive Compression: Automatically selects the best compression scheme based on data patterns.
- Unified Scheme Trait: A single
Schemetrait covers all data types (integers, floats, strings, etc.) with aSchemeIdfor identity. - Cascaded Encoding: Multiple compression layers can be applied for optimal results.
- Statistical Analysis: Uses data sampling and statistics to predict compression ratios.
- Recursive Structure Handling: Compresses nested structures like structs and lists.
§How It Works
BtrBlocksCompressor::compress() takes an &ArrayRef plus a mutable execution context and
returns an ArrayRef that may use a different encoding. It first canonicalizes the input, then dispatches by type.
Primitives and strings go through choose_and_compress, which evaluates every enabled
Scheme and picks the one with the best compression ratio. Compound types like structs
and lists recurse into their fields and elements.
Each Scheme implementation declares whether it matches a given
canonical form and, if so, estimates the compression ratio (often by compressing a ~1%
sample). There is no dynamic registry — the set of schemes is fixed at build time via
ALL_SCHEMES.
Schemes can produce arrays that are themselves further compressed (e.g. FoR then BitPacking),
up to MAX_CASCADE (3) layers deep. Descendant exclusion rules for of SchemeId prevents
the same scheme from being applied twice in a chain.
§Example
use vortex_btrblocks::{BtrBlocksCompressor, BtrBlocksCompressorBuilder, Scheme, SchemeExt};
use vortex_btrblocks::schemes::integer::IntDictScheme;
// Default compressor with all schemes enabled.
let compressor = BtrBlocksCompressor::default();
// Remove specific schemes using the builder.
let compressor = BtrBlocksCompressorBuilder::default()
.exclude_schemes([IntDictScheme.id()])
.build();Modules§
- schemes
- Compression scheme implementations. Compression scheme implementations.
Structs§
- Array
AndStats - An array bundled with its lazily-computed statistics cache.
- Bool
Stats - Array of booleans and relevant stats for compression.
- BtrBlocks
Compressor - The BtrBlocks-style compressor with all built-in schemes pre-registered.
- BtrBlocks
Compressor Builder - Builder for creating configured
BtrBlocksCompressorinstances. - Cascading
Compressor - The main compressor type implementing cascading adaptive compression.
- Compressor
Context - Context passed through recursive compression calls.
- Float
Stats - Array of floating-point numbers and relevant stats for compression.
- Generate
Stats Options - Configures how stats are generated.
- Integer
Stats - Array of integers and relevant stats for compression.
- Scheme
Id - Unique identifier for a compression scheme.
- String
Stats - Array of variable-length byte arrays, and relevant stats for compression.
Constants§
- ALL_
SCHEMES - All available compression schemes.
- MAX_
CASCADE - Maximum cascade depth for compression.
Traits§
- Scheme
- A single compression encoding that the
CascadingCompressorcan select from. - Scheme
Ext - Extension trait providing
idfor allSchemeimplementors.
Functions§
- compress_
patches - Compresses the given patches by downscaling integers and checking for constant values.