pub trait QuantCompressor<T>: Sized + Syncwhere
T: VectorRepr,{
type CompressorContext;
// Required methods
fn new_at_stage(
stage: CompressionStage,
context: &Self::CompressorContext,
) -> ANNResult<Self>;
fn compress(
&self,
vector: MatrixView<'_, f32>,
output: MutMatrixView<'_, u8>,
) -> ANNResult<()>;
fn compressed_bytes(&self) -> usize;
}Expand description
QuantCompressor defines the interface for quantizer with [QuantDataGenerator]
This trait serves as a general wrapper for different quantizers, allowing them to be used interchangeably with QuantDataGenerator. Any type implementing this trait can be used to compress vector data during the data generation process.
§Type Parameters
T: The data type of the input vectors. Must impl Copy + Into+ Pod + Sync so that the [ QuantDataGenerator] can parallelize computation, call compress_into and read from data file.
§Associated Types
- [
CompressorContext]: An overloadable type that provides initialization parameters for the compressor
§Methods
new_at_stage: Constructs a new compressor instance with the provided context for the stage of compression.compress: Compresses a batch of vectors into the output buffer.compressed_bytes: Returns the size in bytes of each compressed vector
Required Associated Types§
Required Methods§
fn new_at_stage( stage: CompressionStage, context: &Self::CompressorContext, ) -> ANNResult<Self>
fn compress( &self, vector: MatrixView<'_, f32>, output: MutMatrixView<'_, u8>, ) -> ANNResult<()>
fn compressed_bytes(&self) -> usize
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.