feat(compress): move dedicated dict support predicate to Rust
Dedicated dictionary search support is a pure compression-parameter policy check. Move its strategy and hash/chain-log comparisons into the Rust parameter module behind a by-value ZSTD_compressionParameters ABI, while leaving the existing C fallback path in createCDict_advanced2 unchanged. Test Plan: - `cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression dedicated_dict_search_support_matches_strategy_and_log_boundaries` -- passed - `make -B -C lib -j2 lib` -- passed - `make -C tests -j2 fuzzer` -- passed - `./tests/fuzzer -s4560 -t47 -i48 -v` -- passed - `cargo clippy --manifest-path rust/Cargo.toml --no-default-features --features compression` -- passed - The same clippy command with `--benches` and `--tests` -- passed - `cargo +nightly fmt --manifest-path rust/Cargo.toml` -- passed - `git diff --cached --check` -- passed
This commit is contained in:
@@ -121,6 +121,7 @@ int ZSTD_rust_params_resolveEnableLdm(
|
||||
int mode, ZSTD_compressionParameters cParams);
|
||||
int ZSTD_rust_params_resolveExternalRepcodeSearch(int mode, int cLevel);
|
||||
int ZSTD_rust_params_cdictIndicesAreTagged(ZSTD_compressionParameters cParams);
|
||||
int ZSTD_rust_params_dedicatedDictSearchIsSupported(ZSTD_compressionParameters cParams);
|
||||
|
||||
/* CCtx parameter state is mirrored by rust/src/zstd_compress_params_api.rs.
|
||||
* Rust owns parameter bounds and clamping; C exposes only the
|
||||
@@ -912,8 +913,6 @@ size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSr
|
||||
static ZSTD_compressionParameters ZSTD_dedicatedDictSearch_getCParams(
|
||||
int const compressionLevel,
|
||||
size_t const dictSize);
|
||||
static int ZSTD_dedicatedDictSearch_isSupported(
|
||||
const ZSTD_compressionParameters* cParams);
|
||||
static void ZSTD_dedicatedDictSearch_revertCParams(
|
||||
ZSTD_compressionParameters* cParams);
|
||||
|
||||
@@ -4131,7 +4130,7 @@ ZSTD_CDict* ZSTD_createCDict_advanced2(
|
||||
&cctxParams, ZSTD_CONTENTSIZE_UNKNOWN, dictSize, ZSTD_cpm_createCDict);
|
||||
}
|
||||
|
||||
if (!ZSTD_dedicatedDictSearch_isSupported(&cParams)) {
|
||||
if (!ZSTD_rust_params_dedicatedDictSearchIsSupported(cParams)) {
|
||||
/* Fall back to non-DDSS params */
|
||||
cctxParams.enableDedicatedDictSearch = 0;
|
||||
cParams = ZSTD_getCParamsFromCCtxParams(
|
||||
@@ -5675,15 +5674,6 @@ static ZSTD_compressionParameters ZSTD_dedicatedDictSearch_getCParams(int const
|
||||
return cParams;
|
||||
}
|
||||
|
||||
static int ZSTD_dedicatedDictSearch_isSupported(
|
||||
ZSTD_compressionParameters const* cParams)
|
||||
{
|
||||
return (cParams->strategy >= ZSTD_greedy)
|
||||
&& (cParams->strategy <= ZSTD_lazy2)
|
||||
&& (cParams->hashLog > cParams->chainLog)
|
||||
&& (cParams->chainLog <= 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses the adjustment applied to cparams when enabling dedicated dict
|
||||
* search. This is used to recover the params set to be used in the working
|
||||
|
||||
Reference in New Issue
Block a user