case ZSTD_p_ldmMinMatch:
case ZSTD_p_ldmBucketSizeLog:
case ZSTD_p_ldmHashEveryLog:
+ case ZSTD_p_forceAttachDict:
default:
return 0;
}
* 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 */
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);
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);
256 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 */
&& cdict->cParams.strategy <= ZSTD_btlazy2
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;
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;
ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize,
* even when referencing into Dictionary content (default:0) */
+ ZSTD_p_forceAttachDict, /* ZSTD supports usage of a CDict in-place
+ * (avoiding having to copy the compression tables
+ * from the CDict into the working context). Using
+ * a CDict in this way saves an initial setup step,
+ * but comes at the cost of more work per byte of
+ * input. ZSTD has a simple internal heuristic that
+ * guesses which strategy will be faster. You can
+ * use this flag to override that guess.
+ *
+ * Note that the by-reference, in-place strategy is
+ * only used when reusing a compression context
+ * with compatible compression parameters. (If
+ * incompatible / uninitialized, the working
+ * context needs to be cleared anyways, which is
+ * about as expensive as overwriting it with the
+ * dictionary context, so there's no savings in
+ * using the CDict by-ref.)
+ *
+ * Values greater than 0 force attaching the dict.
+ * Values less than 0 force copying the dict.
+ * 0 selects the default heuristic-guided behavior.
+ */
} ZSTD_cParameter;
setRand(cctx, ZSTD_p_contentSizeFlag, 0, 1, state);
setRand(cctx, ZSTD_p_checksumFlag, 0, 1, state);
setRand(cctx, ZSTD_p_dictIDFlag, 0, 1, state);
+ setRand(cctx, ZSTD_p_forceAttachDict, -2, 2, state);
/* Select long distance matchig parameters */
setRand(cctx, ZSTD_p_enableLongDistanceMatching, 0, 1, state);
setRand(cctx, ZSTD_p_ldmHashLog, ZSTD_HASHLOG_MIN, 16, state);