]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Remove clevel and update documentation
authorJennifer Liu <jenniferliu620@fb.com>
Sat, 14 Jul 2018 00:38:53 +0000 (17:38 -0700)
committerJennifer Liu <jenniferliu620@fb.com>
Sat, 14 Jul 2018 00:38:53 +0000 (17:38 -0700)
contrib/randomDictBuilder/README.md
contrib/randomDictBuilder/main.c
contrib/randomDictBuilder/test.sh

index cadffdf2734886c43ca02047c25344d85679d7e4..de2c7ff6c723e836097518f55952470a94bc558d 100644 (file)
@@ -1,12 +1,17 @@
 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"
index 15eb5c4403a4cb2601ed5a52adb0d9510d71a9b1..cf0b947698eb93b367083649cffdc2f2ad861bab 100644 (file)
@@ -63,7 +63,7 @@ int main(int argCount, const char* argv[])
   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;
@@ -76,10 +76,10 @@ int main(int argCount, const char* argv[])
   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;
@@ -96,6 +96,11 @@ int main(int argCount, const char* argv[])
     return operationResult;
   }
 
+  if (maxDictSize == 0) {
+    DISPLAYLEVEL(1, "maxDictSize should not be 0.\n");
+    operationResult = 1;
+    return operationResult;
+  }
 
   char* fileNamesBuf = NULL;
   unsigned fileNamesNb = filenameIdx;
@@ -114,7 +119,7 @@ int main(int argCount, const char* argv[])
 
   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;
index 552650ee44c8a5ffa4fd530dd1aa21156da8f34c..497820f8822cc6b24512c9936445474d478e6de4 100644 (file)
@@ -1,8 +1,8 @@
-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