Merge pull request #1200 from felixhandte/zstd-attach-dict-pref
Add CCtx Param Controlling Dict Attachment Behavior
This commit is contained in:
@@ -260,6 +260,7 @@ static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
|
||||
case ZSTD_p_ldmMinMatch:
|
||||
case ZSTD_p_ldmBucketSizeLog:
|
||||
case ZSTD_p_ldmHashEveryLog:
|
||||
case ZSTD_p_forceAttachDict:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -304,6 +305,9 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v
|
||||
* default : 0 when using a CDict, 1 when using a Prefix */
|
||||
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
||||
|
||||
case ZSTD_p_forceAttachDict:
|
||||
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
||||
|
||||
case ZSTD_p_nbWorkers:
|
||||
if ((value>0) && cctx->staticSize) {
|
||||
return ERROR(parameter_unsupported); /* MT not compatible with static alloc */
|
||||
@@ -409,6 +413,12 @@ size_t ZSTD_CCtxParam_setParameter(
|
||||
CCtxParams->forceWindow = (value > 0);
|
||||
return CCtxParams->forceWindow;
|
||||
|
||||
case ZSTD_p_forceAttachDict :
|
||||
CCtxParams->attachDictPref = value ?
|
||||
(value > 0 ? ZSTD_dictForceAttach : ZSTD_dictForceCopy) :
|
||||
ZSTD_dictDefaultAttach;
|
||||
return CCtxParams->attachDictPref;
|
||||
|
||||
case ZSTD_p_nbWorkers :
|
||||
#ifndef ZSTD_MULTITHREAD
|
||||
if (value>0) return ERROR(parameter_unsupported);
|
||||
@@ -512,6 +522,9 @@ size_t ZSTD_CCtxParam_getParameter(
|
||||
case ZSTD_p_forceMaxWindow :
|
||||
*value = CCtxParams->forceWindow;
|
||||
break;
|
||||
case ZSTD_p_forceAttachDict :
|
||||
*value = CCtxParams->attachDictPref;
|
||||
break;
|
||||
case ZSTD_p_nbWorkers :
|
||||
#ifndef ZSTD_MULTITHREAD
|
||||
assert(CCtxParams->nbWorkers == 0);
|
||||
@@ -1243,7 +1256,9 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
|
||||
8 KB /* ZSTD_btultra */
|
||||
};
|
||||
const int attachDict = ( pledgedSrcSize <= attachDictSizeCutoffs[cdict->cParams.strategy]
|
||||
|| pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN )
|
||||
|| pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN
|
||||
|| params.attachDictPref == ZSTD_dictForceAttach )
|
||||
&& params.attachDictPref != ZSTD_dictForceCopy
|
||||
&& !params.forceWindow /* dictMatchState isn't correctly
|
||||
* handled in _enforceMaxDist */
|
||||
&& ZSTD_equivalentCParams(cctx->appliedParams.cParams,
|
||||
|
||||
@@ -48,6 +48,12 @@ extern "C" {
|
||||
typedef enum { ZSTDcs_created=0, ZSTDcs_init, ZSTDcs_ongoing, ZSTDcs_ending } ZSTD_compressionStage_e;
|
||||
typedef enum { zcss_init=0, zcss_load, zcss_flush } ZSTD_cStreamStage;
|
||||
|
||||
typedef enum {
|
||||
ZSTD_dictDefaultAttach = 0,
|
||||
ZSTD_dictForceAttach = 1,
|
||||
ZSTD_dictForceCopy = -1,
|
||||
} ZSTD_dictAttachPref_e;
|
||||
|
||||
typedef struct ZSTD_prefixDict_s {
|
||||
const void* dict;
|
||||
size_t dictSize;
|
||||
@@ -186,6 +192,8 @@ struct ZSTD_CCtx_params_s {
|
||||
int forceWindow; /* force back-references to respect limit of
|
||||
* 1<<wLog, even for dictionary */
|
||||
|
||||
ZSTD_dictAttachPref_e attachDictPref;
|
||||
|
||||
/* Multithreading: used to pass parameters to mtctx */
|
||||
unsigned nbWorkers;
|
||||
unsigned jobSize;
|
||||
|
||||
Reference in New Issue
Block a user