Compressor

Trait Compressor 

Source
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§

Source

type ArrayVTable: VTable

The VTable type for arrays this compressor operates on.

Source

type SchemeType: Scheme<StatsType = Self::StatsType> + ?Sized

The compression scheme type used by this compressor.

Source

type StatsType: CompressorStats<ArrayVTable = Self::ArrayVTable>

The statistics type used to analyze arrays for compression.

Required Methods§

Source

fn schemes() -> &'static [&'static Self::SchemeType]

Returns all available compression schemes for this compressor.

Source

fn default_scheme() -> &'static Self::SchemeType

Returns the default fallback compression scheme.

Source

fn dict_scheme_code() -> <Self::SchemeType as Scheme>::CodeType

Returns the scheme code for dictionary compression.

Provided Methods§

Source

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.

Source

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.

Implementors§

Source§

impl Compressor for FloatCompressor

Source§

type ArrayVTable = PrimitiveVTable

Source§

type SchemeType = dyn FloatScheme<StatsType = FloatStats, CodeType = FloatCode>

Source§

type StatsType = FloatStats

Source§

impl Compressor for IntCompressor

Source§

type ArrayVTable = PrimitiveVTable

Source§

type SchemeType = dyn IntegerScheme<StatsType = IntegerStats, CodeType = IntCode>

Source§

type StatsType = IntegerStats

Source§

impl Compressor for StringCompressor

Source§

type ArrayVTable = VarBinViewVTable

Source§

type SchemeType = dyn StringScheme<StatsType = StringStats, CodeType = StringCode>

Source§

type StatsType = StringStats