Skip to main content

estimated_compression_workspace_bytes_for_parameters

Function estimated_compression_workspace_bytes_for_parameters 

Source
pub fn estimated_compression_workspace_bytes_for_parameters(
    parameters: &CompressionParameters,
    src_size_hint: Option<u64>,
    dictionary: Option<DictionarySizes>,
) -> usize
Expand description

The workspace estimate for a frame run under parameters: the level, every knob that overrides it, the source size and the dictionary, resolved the way the encoder resolves them at frame start.

estimated_compression_workspace_bytes_for_run answers for a level with a window and long-distance matching on top; a caller that also sets hashLog, chainLog, a strategy or the long-distance matcher’s own table sizes needs this one, since each of those resizes what the frame allocates. A dictionary frame runs the geometry the dictionary is prepared with, the knobs included, as the encoder does.

§Examples

use structured_zstd::encoding::{
    estimated_compression_workspace_bytes_for_parameters, CompressionLevel,
    CompressionParameters,
};

let level = CompressionParameters::builder(CompressionLevel::Level(3)).build().unwrap();
let wide = CompressionParameters::builder(CompressionLevel::Level(3))
    .window_log(27)
    .hash_log(24)
    .build()
    .unwrap();
let source = Some(512 << 20);
assert!(
    estimated_compression_workspace_bytes_for_parameters(&wide, source, None)
        > estimated_compression_workspace_bytes_for_parameters(&level, source, None)
);