Random Dictionary Builder
### Permitted Arguments:
-Input Files (in=fileName): files used to build dictionary, can include multiple files, each following "in=", required
+Input File/Directory (in=fileName): required; file/directory used to build dictionary; if directory, will operate recursively for files inside directory; can include multiple files/directories, each following "in="
Output Dictionary (out=dictName): if not provided, default to defaultDict
-Dictionary ID (dictID=#): positive number, if not provided, default to 0
-Maximum Dictionary Size (maxdict=#): positive number, in bytes, if not provided, default to 110KB
-Size of Randomly Selected Segment (k=#): positive number, in bytes, if not provided, default to 200
-Compression Level (c=#): positive number, if not provided, default to 3
+Dictionary ID (dictID=#): nonnegative number; if not provided, default to 0
+Maximum Dictionary Size (maxdict=#): positive number; in bytes, if not provided, default to 110KB
+Size of Randomly Selected Segment (k=#): positive number; in bytes; if not provided, default to 200
+Compression Level (c=#): positive number; if not provided, default to 3
+
+
+###Usage:
+To build a random dictionary with the provided arguments: make run ARG= followed by arguments
+
### Examples:
make run ARG="in=../../lib/dictBuilder out=dict100 dictID=520"
const char* programName = argv[0];
int operationResult = 0;
- unsigned cLevel = DEFAULT_CLEVEL;
+ /* Initialize parameters with default value */
char* inputFile = DEFAULT_INPUTFILE;
unsigned k = DEFAULT_k;
char* outputFile = DEFAULT_OUTPUTFILE;
for (int i = 1; i < argCount; i++) {
const char* argument = argv[i];
if (longCommandWArg(&argument, "k=")) { k = readU32FromChar(&argument); continue; }
- if (longCommandWArg(&argument, "c=")) { cLevel = readU32FromChar(&argument); continue; }
if (longCommandWArg(&argument, "dictID=")) { dictID = readU32FromChar(&argument); continue; }
if (longCommandWArg(&argument, "maxdict=")) { maxDictSize = readU32FromChar(&argument); continue; }
if (longCommandWArg(&argument, "in=")) {
+ /* Allow multiple input files */
inputFile = malloc(strlen(argument) + 1);
strcpy(inputFile, argument);
filenameTable[filenameIdx] = inputFile;
return operationResult;
}
+ if (maxDictSize == 0) {
+ DISPLAYLEVEL(1, "maxDictSize should not be 0.\n");
+ operationResult = 1;
+ return operationResult;
+ }
char* fileNamesBuf = NULL;
unsigned fileNamesNb = filenameIdx;
ZDICT_random_params_t params;
ZDICT_params_t zParams;
- zParams.compressionLevel = cLevel;
+ zParams.compressionLevel = DEFAULT_CLEVEL;
zParams.notificationLevel = displayLevel;
zParams.dictID = dictID;
params.zParams = zParams;
-echo "Building random dictionary with c=5 in=../../lib/common k=200 out=dict1"
-./main c=5 in=../../lib/common k=200 out=dict1
+echo "Building random dictionary with in=../../lib/common k=200 out=dict1"
+./main in=../../lib/common k=200 out=dict1
zstd -be3 -D dict1 -r ../../lib/common -q
-echo "Building random dictionary with c=9 in=../../lib/common k=500 out=dict2 dictID=100 maxdict=140000"
-./main c=9 in=../../lib/common k=500 out=dict2 dictID=100 maxdict=140000
+echo "Building random dictionary with in=../../lib/common k=500 out=dict2 dictID=100 maxdict=140000"
+./main in=../../lib/common k=500 out=dict2 dictID=100 maxdict=140000
zstd -be3 -D dict2 -r ../../lib/common -q
echo "Building random dictionary with 2 sample sources"
./main in=../../lib/common in=../../lib/compress out=dict3