Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug-fix] Make simple single-pass functions ignore advanced parameters #2498

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

terrelln
Copy link
Contributor

The simple compression functions are intended to ignore the advanced
parameters, but they were accidentally using them. All the
ZSTD_parameters were set correctly, but any extra parameters were
used as-is. E.g. ZSTD_c_format.

This PR makes all the simple single-pass functions listed below ignore
the advanced parameters, as intended.

  • ZSTD_compressCCtx()
  • ZSTD_compress_usingDict()
  • ZSTD_compress_usingCDict()
  • ZSTD_compress_advanced()
  • ZSTD_compress_usingCDict_advanced()

It also adds a test case that ensures that each of these functions
ignore the advanced parameters.

params.cParams = ( pledgedSrcSize < ZSTD_USE_CDICT_PARAMS_SRCSIZE_CUTOFF
|| pledgedSrcSize < cdict->dictContentSize * ZSTD_USE_CDICT_PARAMS_DICTSIZE_MULTIPLIER
|| pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN
|| cdict->compressionLevel == 0 )
&& (params.attachDictPref != ZSTD_dictForceLoad) ?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixhandte note this small behavior change with regards to attaching dictionaries. This function is used by ZSTD_compress_usingCDict*(), which doesn't use requestedParams anymore.

cctxParams->cParams = params.cParams;
cctxParams->fParams = params.fParams;
cctxParams->compressionLevel = ZSTD_NO_CLEVEL; /* should not matter, as all cParams are presumed properly defined */
ZSTD_CCtxParams_init_internal(cctxParams, &params, ZSTD_NO_CLEVEL);
return 0;
}

/* ZSTD_assignParamsToCCtxParams() :
Copy link
Contributor

@Cyan4973 Cyan4973 Feb 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: update name in code comment

The simple compression functions are intended to ignore the advanced
parameters, but they were accidentally using them. All the
`ZSTD_parameters` were set correctly, but any extra parameters were
used as-is. E.g. `ZSTD_c_format`.

This PR makes all the simple single-pass functions listed below ignore
the advanced parameters, as intended.

* `ZSTD_compressCCtx()`
* `ZSTD_compress_usingDict()`
* `ZSTD_compress_usingCDict()`
* `ZSTD_compress_advanced()`
* `ZSTD_compress_usingCDict_advanced()`

It also adds a test case that ensures that each of these functions
ignore the advanced parameters.
@terrelln terrelln merged commit bb6ca68 into facebook:dev Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants