1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
use ;
use ;
/// [`CompressionStage`] defines the stage of compression
/// used by the compressor to determine how to instantiate the quantizer
/// (e.g., whether to initialize codebooks for a product quantizer).
/// Passed to [`QuantCompressor::new_at_stage`] when creating quantizer instances.
/// [`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<f32> + 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