Dictionary creation should be after compression format is set
authorJonathan Dieter <jdieter@gmail.com>
Fri, 12 Nov 2021 22:12:53 +0000 (22:12 +0000)
committerJonathan Dieter <jdieter@gmail.com>
Fri, 12 Nov 2021 22:12:53 +0000 (22:12 +0000)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
src/lib/comp/comp.c
src/zck.c

index 7f4547b0e416b3398f3a941a1d1c72deec29c153..02b87878e0bc48f9c6a3f736d39d91d5746024f8 100644 (file)
@@ -378,6 +378,7 @@ bool comp_soption(zckCtx *zck, zck_soption option, const void *value,
         return false;
     }
     if(option == ZCK_COMP_DICT) {
+        zck_log(ZCK_LOG_DEBUG, "Adding dictionary of size %li", length);
         zck->comp.dict = (char *)value;
         zck->comp.dict_size = length;
     } else {
index b99de29a9a807b41f92affb6b77adef3bfd7c6af..c6cf5c57cb828391f3470ef968ade6527a426fd9 100644 (file)
--- a/src/zck.c
+++ b/src/zck.c
@@ -236,23 +236,6 @@ int main (int argc, char *argv[]) {
     }
     free(out_name);
 
-    /*if(!zck_set_ioption(zck, ZCK_COMP_TYPE, ZCK_COMP_NONE)) {
-        perror("Unable to set compression type\n");
-        exit(1);
-    }*/
-    if(dict_size > 0) {
-        if(!zck_set_soption(zck, ZCK_COMP_DICT, dict, dict_size)) {
-            dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck));
-            exit(1);
-        }
-    }
-    free(dict);
-    if(arguments.manual_chunk) {
-        if(!zck_set_ioption(zck, ZCK_MANUAL_CHUNK, 1)) {
-            dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck));
-            exit(1);
-        }
-    }
     if(arguments.compression_format) {
         if(strncmp(arguments.compression_format, "zstd", 4) == 0) {
             if(!zck_set_ioption(zck, ZCK_COMP_TYPE, ZCK_COMP_ZSTD)) {
@@ -269,6 +252,19 @@ int main (int argc, char *argv[]) {
             exit(1);
         }
     }
+    if(dict_size > 0) {
+        if(!zck_set_soption(zck, ZCK_COMP_DICT, dict, dict_size)) {
+            dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck));
+            exit(1);
+        }
+    }
+    free(dict);
+    if(arguments.manual_chunk) {
+        if(!zck_set_ioption(zck, ZCK_MANUAL_CHUNK, 1)) {
+            dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck));
+            exit(1);
+        }
+    }
     if(arguments.uncompressed) {
         if(!zck_set_ioption(zck, ZCK_UNCOMP_HEADER, 1)) {
             dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck));