Available on crate feature
dict-builder only.Expand description
Dictionary training.
Effective dictionaries are up to 1% the size of the complete training body, and are trained on many examples of the original data. The trainers are those of the reference implementation, each taking the samples back to back with their sizes:
- COVER (
train_cover_dict,optimize_cover_dict) indexes every dmer exactly and fills the dictionary with the segments whose dmers the most samples share. - FastCOVER (
train_fastcover_dict,optimize_fastcover_dict) does the same over a hashed frequency table, faster and with less memory; it is whatzstd --trainruns. - The legacy trainer (
create_legacy_dict_from_slice) searches a suffix array for repeated segments.
The optimize_* forms search segment and dmer sizes, scoring each candidate
by the total size of the scoring samples compressed with it.
create_raw_dict_from_slice and its reader and directory forms build raw
content, with no entropy tables, from a corpus without sample sizes: the
FastCOVER search zstd --train runs, over the corpus cut into samples.
Structs§
- Cover
Options - Tuning for COVER training, the knobs of the reference’s
ZDICT_cover_params_t. - Fast
Cover Options - Tuning for FastCOVER training, the knobs of the reference’s
ZDICT_fastCover_params_t. - Finalize
Options - How a dictionary is finalized and trained against, the reference’s
ZDICT_params_t.
Enums§
- Training
Error - Why a segment trainer or the finalizer refused its input. It rides inside
the
InvalidInputerror returned;TrainingError::ofreads it back.
Constants§
- DEFAULT_
SELECTIVITY - Selectivity the reference uses when none is given (
g_selectivity_default). - MIN_
TRAINED_ DICT_ SIZE - Smallest
dict_sizea dictionary is trained or finalized into (upstream zstdZDICT_DICTSIZE_MIN).
Functions§
- check_
cover_ options - Refuse COVER tuning no training run can use for a
dict_sizedictionary, from the options alone: whattrain_cover_dict(bothkanddgiven) oroptimize_cover_dict(either left zero) would refuse before reading a sample. Lets a caller holding a large corpus fail before loading it. - check_
cover_ sample_ count - Refuse
sample_countsamples the COVER trainingoptionsselect cannot build from: too few once the split takes its scoring share, or none left to score on. Needs only the count, so a caller can ask before reading a sample. - check_
fastcover_ options check_cover_optionsfor FastCOVER: also refusesf,acceland adbelow 4 astrain_fastcover_dictandoptimize_fastcover_dictdo.- check_
fastcover_ sample_ count check_cover_sample_countfor FastCOVER, whose search scores on a quarter of the samples unlesssplit_pointsays otherwise.- check_
finalize_ dict_ size - Refuse a
dict_sizefinalize_raw_dictcannot fill, from the size alone: belowMIN_TRAINED_DICT_SIZE. Finalizing checks it first, before the samples; a caller holding the samples somewhere costly to walk can run it before that. - create_
legacy_ dict_ from_ slice - Train and finalize a dictionary with the reference’s original trainer, the
one
zstd --train-legacyruns (ZDICT_trainFromBuffer_legacy). - create_
raw_ dict_ from_ dir - Create a “raw content” dictionary of at most
dict_sizebytes, with no entropy tables, from every file in this directory and its subdirectories, and write it tooutput. - create_
raw_ dict_ from_ slice - Create a “raw content” dictionary of at most
dict_sizebytes, with no entropy tables, from a corpus already in memory, writing it tooutput. - create_
raw_ dict_ from_ source - Read from
sourceto create a “raw content” dictionary ofdict_size. The completed dictionary is written tooutput. - finalize_
raw_ dict - Finalize raw dictionary content into a dictionary of at most
dict_sizebytes: magic, id, entropy tables, repeat offsets and the content (the reference’sZDICT_finalizeDictionary). - optimize_
cover_ dict - Train COVER dictionaries over a range of
kanddand keep the one the scoring samples compress best with (the reference’sZDICT_optimizeTrainFromBuffer_cover). Returns it with the options that built it. - optimize_
fastcover_ dict - Train FastCOVER dictionaries over a range of
kanddand keep the one the scoring samples compress best with (the reference’sZDICT_optimizeTrainFromBuffer_fastCover, whichzstd --trainandZDICT_trainFromBufferrun). Returns it with the options that built it. - train_
cover_ dict - Train a COVER dictionary of at most
dict_sizebytes with thekanddgiven (the reference’sZDICT_trainFromBuffer_cover). - train_
fastcover_ dict - Train a FastCOVER dictionary of at most
dict_sizebytes with thekanddgiven (the reference’sZDICT_trainFromBuffer_fastCover).