summaryrefslogtreecommitdiffstats
path: root/lib/lz4frame_static.h
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-08-09 23:51:19 (GMT)
committerYann Collet <cyan@fb.com>2017-08-09 23:51:19 (GMT)
commit31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad (patch)
tree5dc0309a412fbf5bf40caea48094115dc4eb9c97 /lib/lz4frame_static.h
parent1d1737aaf28c60d3cf6950b545f6a844afe422c0 (diff)
downloadlz4-31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad.zip
lz4-31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad.tar.gz
lz4-31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad.tar.bz2
implemented dictionary compression in lz4frame
note : only compression API is implemented and tested still to do : decompression API
Diffstat (limited to 'lib/lz4frame_static.h')
-rw-r--r--lib/lz4frame_static.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/lz4frame_static.h b/lib/lz4frame_static.h
index d3bae82..5f22aed 100644
--- a/lib/lz4frame_static.h
+++ b/lib/lz4frame_static.h
@@ -82,6 +82,50 @@ typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) } LZ4F_errorCodes;
LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult);
+
+/**********************************
+ * Bulk processing dictionary API
+ *********************************/
+typedef struct LZ4F_CDict_s LZ4F_CDict;
+
+/*! LZ4_createCDict() :
+ * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
+ * LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
+ * LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
+ * `dictBuffer` can be released after LZ4_CDict creation, since its content is copied within CDict */
+LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize);
+void LZ4F_freeCDict(LZ4F_CDict* CDict);
+
+/*! LZ4_compressFrame_usingCDict() :
+ * Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary.
+ * If cdict==NULL, compress without a dictionary.
+ * dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
+ * If this condition is not respected, function will fail (@return an errorCode).
+ * The LZ4F_preferences_t structure is optional : you may provide NULL as argument,
+ * but it's not recommended, as it's the only way to provide dictID in the frame header.
+ * @return : number of bytes written into dstBuffer.
+ * or an error code if it fails (can be tested using LZ4F_isError())
+ */
+size_t LZ4F_compressFrame_usingCDict(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const LZ4F_CDict* cdict,
+ const LZ4F_preferences_t* preferencesPtr);
+
+
+/*! LZ4F_compressBegin_usingCDict() :
+ * Inits streaming dictionary compression, and writes the frame header into dstBuffer.
+ * dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
+ * `prefsPtr` is optional : you may provide NULL as argument,
+ * however, it's the only way to provide dictID in the frame header.
+ * @return : number of bytes written into dstBuffer for the header,
+ * or an error code (which can be tested using LZ4F_isError())
+ */
+size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctx,
+ void* dstBuffer, size_t dstCapacity,
+ const LZ4F_CDict* cdict,
+ const LZ4F_preferences_t* prefsPtr);
+
+
#if defined (__cplusplus)
}
#endif