pub trait Compressor {
type ArrayVTable: VTable;
type SchemeType: Scheme<StatsType = Self::StatsType> + ?Sized;
type StatsType: CompressorStats<ArrayVTable = Self::ArrayVTable>;
// Required methods
fn schemes() -> &'static [&'static Self::SchemeType];
fn default_scheme() -> &'static Self::SchemeType;
fn dict_scheme_code() -> <Self::SchemeType as Scheme>::CodeType;
// Provided methods
fn compress(
array: &<Self::ArrayVTable as VTable>::Array,
is_sample: bool,
allowed_cascading: usize,
excludes: &[<Self::SchemeType as Scheme>::CodeType],
) -> VortexResult<ArrayRef>
where Self::SchemeType: 'static { ... }
fn choose_scheme(
stats: &Self::StatsType,
is_sample: bool,
allowed_cascading: usize,
excludes: &[<Self::SchemeType as Scheme>::CodeType],
) -> VortexResult<&'static Self::SchemeType> { ... }
}Expand description
A compressor for a particular input type.
This trait defines the interface for type-specific compressors that can adaptively choose and apply compression schemes based on data characteristics. Compressors analyze input arrays, select optimal compression schemes, and handle cascading compression with multiple encoding layers.
The compressor works by generating statistics on the input data, evaluating available compression schemes, and selecting the one with the best compression ratio.
Required Associated Types§
Sourcetype ArrayVTable: VTable
type ArrayVTable: VTable
The VTable type for arrays this compressor operates on.
Sourcetype SchemeType: Scheme<StatsType = Self::StatsType> + ?Sized
type SchemeType: Scheme<StatsType = Self::StatsType> + ?Sized
The compression scheme type used by this compressor.
Sourcetype StatsType: CompressorStats<ArrayVTable = Self::ArrayVTable>
type StatsType: CompressorStats<ArrayVTable = Self::ArrayVTable>
The statistics type used to analyze arrays for compression.
Required Methods§
Sourcefn schemes() -> &'static [&'static Self::SchemeType]
fn schemes() -> &'static [&'static Self::SchemeType]
Returns all available compression schemes for this compressor.
Sourcefn default_scheme() -> &'static Self::SchemeType
fn default_scheme() -> &'static Self::SchemeType
Returns the default fallback compression scheme.
Sourcefn dict_scheme_code() -> <Self::SchemeType as Scheme>::CodeType
fn dict_scheme_code() -> <Self::SchemeType as Scheme>::CodeType
Returns the scheme code for dictionary compression.
Provided Methods§
Sourcefn compress(
array: &<Self::ArrayVTable as VTable>::Array,
is_sample: bool,
allowed_cascading: usize,
excludes: &[<Self::SchemeType as Scheme>::CodeType],
) -> VortexResult<ArrayRef>where
Self::SchemeType: 'static,
fn compress(
array: &<Self::ArrayVTable as VTable>::Array,
is_sample: bool,
allowed_cascading: usize,
excludes: &[<Self::SchemeType as Scheme>::CodeType],
) -> VortexResult<ArrayRef>where
Self::SchemeType: 'static,
Compresses an array using the optimal compression scheme.
Generates statistics on the input array, selects the best compression scheme, and applies it. Returns the original array if compression would increase size.
Sourcefn choose_scheme(
stats: &Self::StatsType,
is_sample: bool,
allowed_cascading: usize,
excludes: &[<Self::SchemeType as Scheme>::CodeType],
) -> VortexResult<&'static Self::SchemeType>
fn choose_scheme( stats: &Self::StatsType, is_sample: bool, allowed_cascading: usize, excludes: &[<Self::SchemeType as Scheme>::CodeType], ) -> VortexResult<&'static Self::SchemeType>
Selects the best compression scheme based on expected compression ratios.
Evaluates all available schemes against the provided statistics and returns the one with the highest compression ratio. Falls back to the default scheme if no scheme provides compression benefits.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.