pub struct Encoder<F: AlpFloat> {
pub cached_params: Option<BestParams>,
pub cached_use_repeat: Option<bool>,
pub cached_scheme: Option<CachedScheme>,
pub cached_target_bw: CachedTargetBw,
pub cached_use_delta: Option<bool>,
/* private fields */
}Expand description
Stateful encoder that caches optimal parameters and scratch buffers across adjacent chunks. 状态化编码器:在连续数据块编码时复用已探测的最优参数与内部工作缓冲区,消除重复采样开销与内存分配。
Fields§
§cached_params: Option<BestParams>§cached_use_repeat: Option<bool>§cached_scheme: Option<CachedScheme>§cached_target_bw: CachedTargetBw§cached_use_delta: Option<bool>Implementations§
Source§impl<F: AlpFloat> Encoder<F>
impl<F: AlpFloat> Encoder<F>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new encoder (empty buffers, dynamically allocated on demand and reused). 创建新的编码器(空缓冲区,按需动态分配并长久复用)
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an encoder with specified initial capacity (pre-allocated buffers for zero heap allocation). 创建具有指定初始容量的编码器(预分配缓冲区,实现全程零堆分配)
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets cached optimal parameters and clears internal buffers. 重置已缓存的最优参数与内部缓冲区
Sourcepub fn compress_into(&mut self, data: &[F], dst: &mut Vec<u8>)
pub fn compress_into(&mut self, data: &[F], dst: &mut Vec<u8>)
Compresses float data slice into destination buffer (adaptive FOR/Delta, reusing parameters and memory). 压缩浮点数据切片并写入目标缓冲区(自适应 FOR 或 Delta 模式,复用采样参数与工作内存)
Sourcepub fn compress_delta_into(&mut self, data: &[F], dst: &mut Vec<u8>)
pub fn compress_delta_into(&mut self, data: &[F], dst: &mut Vec<u8>)
Compresses float data slice using Delta differential mode into destination buffer. 强制使用 Delta 差分模式压缩浮点数据切片并写入目标缓冲区
Sourcepub fn compress(&mut self, data: &[F]) -> Vec<u8> ⓘ
pub fn compress(&mut self, data: &[F]) -> Vec<u8> ⓘ
Compresses float data slice and returns newly allocated byte vector. 压缩浮点数据切片并返回新分配的字节向量
Sourcepub fn compress_delta(&mut self, data: &[F]) -> Vec<u8> ⓘ
pub fn compress_delta(&mut self, data: &[F]) -> Vec<u8> ⓘ
Compresses float data slice using Delta differential mode and returns newly allocated byte vector. 强制使用 Delta 差分模式压缩浮点数据切片并返回新分配的字节向量
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the internal work buffer as much as possible. 释放内部工作缓冲区多余分配的容量