Expand description
ZSTD dictionary training — writer-side API.
Wraps limnifs_core::codec::zstd_dict (which wraps
omnizip_zstd::train_dictionary) at the writer layer. The
codec-layer API takes raw samples; this layer adds:
- Per-content-class sample collection (text, binary, etc.).
- Configurable trainer (FrequencyTrainer today; FastCover via
omnizip_zstd::FastCoverTrainerwhen needed). - Dictionary id allocation (0x00..=0xFE; 0xFF is
NO_DICT). - Integration with
WriteConfig::dictionaries.
§Pipeline integration (planned)
Today this module exposes the trainer; the writer pipeline does
NOT yet call it. The plan, filed in
TODO.impl/04-writer-pipeline/04-zstd-dictionary-training.md:
- Walk + parallel chunk + compress (existing pipeline).
- Collect unique plaintext drops per content class during
merge_chunked_file. - After parallel phase, train one dict per class with ≥
min_class_sizedrops. - Re-compress eligible drops with
compress_with_dict; keep the smaller of (original, dict-compressed). - Drop records carry
dict_id; manifest emitsdictionary_section.
This module is the public API for steps 3–4. The pipeline glue lands in a follow-up PR.
Structs§
- Trained
Dictionary - Trained dictionary ready for use with
compress_with_dict.
Enums§
- Trainer
Kind - Trainer algorithm selection. See
train_zstd_with_trainer.
Constants§
- DEFAULT_
MIN_ SAMPLES - Minimum sample count before training is worthwhile. Below this,
the trainer returns empty (not enough signal). Matches
DictionaryConfig::min_class_sizedefault. - DEFAULT_
TARGET_ SIZE - Default target dictionary size (64 KiB). Matches
DictionaryConfig::max_dict_sizedefault.
Functions§
- allocate_
ids - Allocate dictionary ids 0x00..=0xFE for a set of trained dicts.
The 0xFF slot is reserved as
NO_DICTsentinel. - train_
zstd - Train a ZSTD dictionary from
samplesusing the default FrequencyTrainer. ReturnsNoneifsamplesis empty, target size is 0, or the trainer produces an empty dictionary (not enough signal). - train_
zstd_ with_ trainer - Train with explicit trainer selection. See
train_zstdfor the default-FrequencyTrainer shortcut.