pub fn train_fastcover_dict(
samples: &[u8],
sample_sizes: &[usize],
dict_size: usize,
options: &FastCoverOptions,
finalize: FinalizeOptions,
) -> Result<Vec<u8>>Available on crate feature
dict-builder only.Expand description
Train a FastCOVER dictionary of at most dict_size bytes with the k and
d given (the reference’s ZDICT_trainFromBuffer_fastCover).
As train_cover_dict, over a hashed frequency table of 2^f counts; the
entropy tables are drawn from the share of samples accel sets.
§Errors
As train_cover_dict, and when d is below 4, f exceeds 31 or accel
exceeds 10. A table too large for memory is an OutOfMemory error.
§Examples
use structured_zstd::dictionary::{
CoverOptions, FastCoverOptions, FinalizeOptions, train_fastcover_dict,
};
let mut samples = Vec::new();
let mut sizes = Vec::new();
for i in 0..200u32 {
let line = format!("tenant=demo table=orders key={i} region=eu status=shipped\n");
sizes.push(line.len());
samples.extend_from_slice(line.as_bytes());
}
let options = FastCoverOptions {
cover: CoverOptions { k: 64, ..FastCoverOptions::default().cover },
..FastCoverOptions::default()
};
let dict = train_fastcover_dict(&samples, &sizes, 4096, &options, FinalizeOptions::default())
.unwrap();
assert!(dict.len() <= 4096);