Skip to main content

encode

Function encode 

Source
pub fn encode(
    codec_id: CodecId,
    vector: &[f32],
    seed: u64,
) -> Result<Vec<u8>, CompressionError>
Expand description

Encode a vector through the codec specified by codec_id.

The function is symmetric to decode for Uncompressed, TurboQuant, and FibQuant. For Polar and Qjl (asymmetric codecs) the encode path produces a sketch/code that does not admit full reconstruction; the round-trip decode(encode(v)) returns the same wire bytes.

§Errors

Returns CompressionError if the codec is unavailable, the profile cannot be built (e.g., dim not divisible by k for fib_quant), or the underlying codec encode fails.