minor : createDictionaryBuffer() can create dictionaries of different sizes
This commit is contained in:
@@ -131,25 +131,28 @@ static buffer_t createBuffer_fromFile(const char* fileName)
|
|||||||
static buffer_t
|
static buffer_t
|
||||||
createDictionaryBuffer(const char* dictionaryName,
|
createDictionaryBuffer(const char* dictionaryName,
|
||||||
const void* srcBuffer,
|
const void* srcBuffer,
|
||||||
const size_t* srcBlockSizes, unsigned nbBlocks)
|
const size_t* srcBlockSizes, unsigned nbBlocks,
|
||||||
|
size_t requestedDictSize)
|
||||||
{
|
{
|
||||||
if (dictionaryName) {
|
if (dictionaryName) {
|
||||||
DISPLAYLEVEL(3, "loading dictionary %s \n", dictionaryName);
|
DISPLAYLEVEL(3, "loading dictionary %s \n", dictionaryName);
|
||||||
return createBuffer_fromFile(dictionaryName);
|
return createBuffer_fromFile(dictionaryName);
|
||||||
} else {
|
|
||||||
DISPLAYLEVEL(3, "creating dictionary, of target size %u bytes \n", DICTSIZE);
|
|
||||||
void* const dictBuffer = malloc(DICTSIZE);
|
|
||||||
assert(dictBuffer != NULL);
|
|
||||||
|
|
||||||
size_t const dictSize = ZDICT_trainFromBuffer(dictBuffer, DICTSIZE,
|
} else {
|
||||||
srcBuffer,
|
|
||||||
srcBlockSizes,
|
DISPLAYLEVEL(3, "creating dictionary, of target size %u bytes \n",
|
||||||
nbBlocks);
|
(unsigned)requestedDictSize);
|
||||||
assert(!ZSTD_isError(dictSize));
|
void* const dictBuffer = malloc(requestedDictSize);
|
||||||
|
CONTROL(dictBuffer != NULL);
|
||||||
|
|
||||||
|
size_t const dictSize = ZDICT_trainFromBuffer(dictBuffer, requestedDictSize,
|
||||||
|
srcBuffer,
|
||||||
|
srcBlockSizes, nbBlocks);
|
||||||
|
CONTROL(!ZSTD_isError(dictSize));
|
||||||
|
|
||||||
buffer_t result;
|
buffer_t result;
|
||||||
result.ptr = dictBuffer;
|
result.ptr = dictBuffer;
|
||||||
result.capacity = DICTSIZE;
|
result.capacity = requestedDictSize;
|
||||||
result.size = dictSize;
|
result.size = dictSize;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -616,7 +619,8 @@ int bench(const char** fileNameTable, unsigned nbFiles,
|
|||||||
/* dictionary determination */
|
/* dictionary determination */
|
||||||
buffer_t const dictBuffer = createDictionaryBuffer(dictionary,
|
buffer_t const dictBuffer = createDictionaryBuffer(dictionary,
|
||||||
srcBuffer.ptr,
|
srcBuffer.ptr,
|
||||||
srcSlices.capacities, nbBlocks);
|
srcSlices.capacities, nbBlocks,
|
||||||
|
DICTSIZE);
|
||||||
CONTROL(dictBuffer.ptr != NULL);
|
CONTROL(dictBuffer.ptr != NULL);
|
||||||
|
|
||||||
ZSTD_CDict* const cdict = ZSTD_createCDict(dictBuffer.ptr, dictBuffer.size, clevel);
|
ZSTD_CDict* const cdict = ZSTD_createCDict(dictBuffer.ptr, dictBuffer.size, clevel);
|
||||||
|
|||||||
Reference in New Issue
Block a user