Skip to main content

Module compression

Module compression 

Source
Expand description

Compression utilities for tiles. The format is zstd-only — there is no gzip path (it was never shipped; zstd beats it on both ratio and browser decode). Compression::None exists only for already-incompressible blobs.

Constants§

ZSTD_LEVEL
Default zstd level. Level 3 is zstd’s documented “fast” sweet spot — roughly gzip-6 ratio at ~5x the encode speed; higher levels save a few percent at significant CPU cost. Default zstd level for the packed format — see the constant doc above. compress_zstd_with_dict and the writers use this unless an explicit level is threaded through (e.g. stt-build --zstd-level).
ZSTD_LEVEL_MAX
Highest level we expose. zstd defines 1..=22; level 19 is the practical ceiling (19 ≈ 22 on STT tiles, measured) but we accept up to 22.

Functions§

compress
Compress data using the specified compression method
compress_zstd_with_dict
Compress a payload with zstd using an optional pre-shared dictionary, at the default level (ZSTD_LEVEL). Thin wrapper over compress_zstd_with_dict_level — kept as the stable call site for the many writers that don’t tune the level.
compress_zstd_with_dict_level
Compress a payload with zstd at an explicit level, with an optional pre-shared dictionary.
decompress
Decompress data using the specified compression method
decompress_zstd_with_dict
Decompress zstd data, applying a pre-shared dictionary when supplied.
train_zstd_dictionary
Train a zstd dictionary from a sample of payloads.
train_zstd_dictionary_from_slices
Train a zstd dictionary from borrowed payload slices (no cloning).