TimelessMetrics.DictTrainer (timeless_metrics v6.0.16)

Copy Markdown View Source

Manages zstd dictionaries for improved compression of Gorilla-compressed segments.

On startup, loads any existing dictionary from data_dir/dict_v*.zstd. Stores compiled cdict/ddict in persistent_term for zero-cost access during compression and decompression.

Dictionaries are trained via mix tm.train_dict or train/2.

Summary

Functions

Returns a specification to start this module under a supervisor.

Get the compiled compression dictionary for a store, or nil if none.

Get the compiled decompression dictionary for a store, or nil if none.

Get the raw dictionary binary for a store, or nil if none.

Get the dictionary version for a store, or 0 if none.

Train a dictionary from existing segment data.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_cdict(store)

Get the compiled compression dictionary for a store, or nil if none.

get_ddict(store)

Get the compiled decompression dictionary for a store, or nil if none.

get_dict(store)

Get the raw dictionary binary for a store, or nil if none.

get_dict_version(store)

Get the dictionary version for a store, or 0 if none.

start_link(opts)

train(store, opts \\ [])

Train a dictionary from existing segment data.

Reads Gorilla-compressed blobs (pre-zstd) from the store's segments, uses them as training samples for zstd dictionary building.

Options:

  • :sample_count - Number of segments to sample (default: 500)
  • :compression_level - zstd compression level for the cdict (default: 9)
  • :version - Dictionary version number (default: auto-increment)