mirror of
https://github.com/facebook/zstd.git
synced 2025-10-11 00:03:06 -04:00
Merge pull request #1466 from facebook/noDictPresent
fixed : better error message
This commit is contained in:
commit
8f35c7f94c
@ -27,18 +27,18 @@ void ZSTD_fillHashTable(ZSTD_matchState_t* ms,
|
|||||||
/* Always insert every fastHashFillStep position into the hash table.
|
/* Always insert every fastHashFillStep position into the hash table.
|
||||||
* Insert the other positions if their hash entry is empty.
|
* Insert the other positions if their hash entry is empty.
|
||||||
*/
|
*/
|
||||||
for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
|
for ( ; ip + fastHashFillStep < iend + 2; ip += fastHashFillStep) {
|
||||||
U32 const current = (U32)(ip - base);
|
U32 const current = (U32)(ip - base);
|
||||||
U32 i;
|
size_t const hash0 = ZSTD_hashPtr(ip, hBits, mls);
|
||||||
for (i = 0; i < fastHashFillStep; ++i) {
|
hashTable[hash0] = current;
|
||||||
size_t const hash = ZSTD_hashPtr(ip + i, hBits, mls);
|
if (dtlm == ZSTD_dtlm_fast) continue;
|
||||||
if (i == 0 || hashTable[hash] == 0)
|
|
||||||
hashTable[hash] = current + i;
|
|
||||||
/* Only load extra positions for ZSTD_dtlm_full */
|
/* Only load extra positions for ZSTD_dtlm_full */
|
||||||
if (dtlm == ZSTD_dtlm_fast)
|
{ U32 p;
|
||||||
break;
|
for (p = 1; p < fastHashFillStep; ++p) {
|
||||||
}
|
size_t const hash = ZSTD_hashPtr(ip + p, hBits, mls);
|
||||||
}
|
if (hashTable[hash] == 0) { /* not yet filled */
|
||||||
|
hashTable[hash] = current + p;
|
||||||
|
} } } }
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE_TEMPLATE
|
FORCE_INLINE_TEMPLATE
|
||||||
|
@ -23,8 +23,9 @@
|
|||||||
#include "platform.h" /* Large Files support */
|
#include "platform.h" /* Large Files support */
|
||||||
#include "util.h" /* UTIL_getFileSize, UTIL_sleep */
|
#include "util.h" /* UTIL_getFileSize, UTIL_sleep */
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset, strerror */
|
||||||
#include <stdio.h> /* fprintf, fopen */
|
#include <stdio.h> /* fprintf, fopen */
|
||||||
|
#include <errno.h>
|
||||||
#include <assert.h> /* assert */
|
#include <assert.h> /* assert */
|
||||||
|
|
||||||
#include "benchfn.h"
|
#include "benchfn.h"
|
||||||
@ -799,6 +800,11 @@ BMK_benchOutcome_t BMK_benchFilesAdvanced(
|
|||||||
/* Load dictionary */
|
/* Load dictionary */
|
||||||
if (dictFileName != NULL) {
|
if (dictFileName != NULL) {
|
||||||
U64 const dictFileSize = UTIL_getFileSize(dictFileName);
|
U64 const dictFileSize = UTIL_getFileSize(dictFileName);
|
||||||
|
if (dictFileSize == UTIL_FILESIZE_UNKNOWN) {
|
||||||
|
DISPLAYLEVEL(1, "error loading %s : %s \n", dictFileName, strerror(errno));
|
||||||
|
free(fileSizes);
|
||||||
|
RETURN_ERROR(9, BMK_benchOutcome_t, "benchmark aborted");
|
||||||
|
}
|
||||||
if (dictFileSize > 64 MB) {
|
if (dictFileSize > 64 MB) {
|
||||||
free(fileSizes);
|
free(fileSizes);
|
||||||
RETURN_ERROR(10, BMK_benchOutcome_t, "dictionary file %s too large", dictFileName);
|
RETURN_ERROR(10, BMK_benchOutcome_t, "dictionary file %s too large", dictFileName);
|
||||||
|
@ -494,6 +494,7 @@ static size_t FIO_createDictBuffer(void** bufferPtr, const char* fileName)
|
|||||||
DISPLAYLEVEL(4,"Loading %s as dictionary \n", fileName);
|
DISPLAYLEVEL(4,"Loading %s as dictionary \n", fileName);
|
||||||
fileHandle = fopen(fileName, "rb");
|
fileHandle = fopen(fileName, "rb");
|
||||||
if (fileHandle==NULL) EXM_THROW(31, "%s: %s", fileName, strerror(errno));
|
if (fileHandle==NULL) EXM_THROW(31, "%s: %s", fileName, strerror(errno));
|
||||||
|
|
||||||
fileSize = UTIL_getFileSize(fileName);
|
fileSize = UTIL_getFileSize(fileName);
|
||||||
if (fileSize > DICTSIZE_MAX) {
|
if (fileSize > DICTSIZE_MAX) {
|
||||||
EXM_THROW(32, "Dictionary file %s is too large (> %u MB)",
|
EXM_THROW(32, "Dictionary file %s is too large (> %u MB)",
|
||||||
@ -502,7 +503,7 @@ static size_t FIO_createDictBuffer(void** bufferPtr, const char* fileName)
|
|||||||
*bufferPtr = malloc((size_t)fileSize);
|
*bufferPtr = malloc((size_t)fileSize);
|
||||||
if (*bufferPtr==NULL) EXM_THROW(34, "%s", strerror(errno));
|
if (*bufferPtr==NULL) EXM_THROW(34, "%s", strerror(errno));
|
||||||
{ size_t const readSize = fread(*bufferPtr, 1, (size_t)fileSize, fileHandle);
|
{ size_t const readSize = fread(*bufferPtr, 1, (size_t)fileSize, fileHandle);
|
||||||
if (readSize!=fileSize)
|
if (readSize != fileSize)
|
||||||
EXM_THROW(35, "Error reading dictionary file %s : %s",
|
EXM_THROW(35, "Error reading dictionary file %s : %s",
|
||||||
fileName, strerror(errno));
|
fileName, strerror(errno));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user