multi_compress 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/GET_STARTED.md +4 -2
- data/README.md +1 -1
- data/THIRD_PARTY_NOTICES.md +2 -2
- data/ext/multi_compress/exports.darwin +1 -0
- data/ext/multi_compress/exports.map +4 -0
- data/ext/multi_compress/extconf.rb +20 -0
- data/ext/multi_compress/multi_compress.c +123 -73
- data/ext/multi_compress/vendor/.vendored +1 -1
- data/ext/multi_compress/vendor/zstd/lib/BUCK +10 -5
- data/ext/multi_compress/vendor/zstd/lib/README.md +25 -5
- data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +6 -2
- data/ext/multi_compress/vendor/zstd/lib/common/bits.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +3 -3
- data/ext/multi_compress/vendor/zstd/lib/common/bmi2.h +40 -0
- data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +37 -11
- data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +7 -6
- data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +4 -3
- data/ext/multi_compress/vendor/zstd/lib/common/pool.c +16 -19
- data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +31 -0
- data/ext/multi_compress/vendor/zstd/lib/common/threading.c +16 -2
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +9 -0
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +4 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +300 -3
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +4 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +4 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +775 -214
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +35 -6
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +9 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +14 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +2 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +2 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +49 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +11 -11
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +11 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +16 -18
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +3 -3
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +64 -39
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +30 -2
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +78 -64
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +182 -18
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +59 -27
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +11 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +194 -93
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +225 -85
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +19 -2
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +136 -91
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.c +77 -77
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +48 -42
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +18 -14
- data/ext/multi_compress/vendor/zstd/lib/dll/example/build_package.bat +66 -20
- data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +10 -6
- data/ext/multi_compress/vendor/zstd/lib/install_oses.mk +17 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +10 -8
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +5 -364
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +4 -5
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +7 -3
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +8 -5
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +3 -3
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +1 -0
- data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +8 -7
- data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +1 -0
- data/ext/multi_compress/vendor/zstd/lib/module.modulemap +0 -21
- data/ext/multi_compress/vendor/zstd/lib/zstd.h +209 -112
- data/lib/multi_compress/reader/read_operations.rb +2 -0
- data/lib/multi_compress/version.rb +1 -1
- data/multi_compress.gemspec +2 -0
- data/mysql_udf/Makefile +12 -5
- data/mysql_udf/multi_compress_mysql.exports +6 -0
- data/postgres_extension/Makefile +2 -1
- data/postgres_extension/test/run_e2e.sh +28 -10
- metadata +6 -5
- data/ext/multi_compress/vendor/lz4/lib/Makefile +0 -244
- data/ext/multi_compress/vendor/lz4/lib/dll/example/Makefile +0 -63
- data/ext/multi_compress/vendor/zstd/lib/Makefile +0 -389
- data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +0 -48
|
@@ -110,8 +110,8 @@ extern "C" {
|
|
|
110
110
|
|
|
111
111
|
/*------ Version ------*/
|
|
112
112
|
#define ZSTD_VERSION_MAJOR 1
|
|
113
|
-
#define ZSTD_VERSION_MINOR
|
|
114
|
-
#define ZSTD_VERSION_RELEASE
|
|
113
|
+
#define ZSTD_VERSION_MINOR 6
|
|
114
|
+
#define ZSTD_VERSION_RELEASE 0
|
|
115
115
|
#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
|
|
116
116
|
|
|
117
117
|
/*! ZSTD_versionNumber() :
|
|
@@ -176,30 +176,30 @@ ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
|
|
|
176
176
|
|
|
177
177
|
/*====== Decompression helper functions ======*/
|
|
178
178
|
|
|
179
|
-
/*!
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
|
|
179
|
+
/*! @brief Returns the decompressed content size stored in a ZSTD frame header.
|
|
180
|
+
*
|
|
181
|
+
* @since v1.3.0
|
|
182
|
+
*
|
|
183
|
+
* @param src Pointer to the beginning of a ZSTD encoded frame.
|
|
184
|
+
* @param srcSize Size of the buffer pointed to by @p src. It must be at least as large as the frame header.
|
|
185
|
+
* Any value greater than or equal to `ZSTD_frameHeaderSize_max` is sufficient.
|
|
186
|
+
* @return The decompressed size in bytes when the value is available in the frame header.
|
|
187
|
+
* @retval ZSTD_CONTENTSIZE_UNKNOWN The frame does not encode a decompressed size (typical for streaming).
|
|
188
|
+
* @retval ZSTD_CONTENTSIZE_ERROR An error occurred (e.g. invalid magic number, @p srcSize too small).
|
|
189
|
+
*
|
|
190
|
+
* @note The return value is not compatible with `ZSTD_isError()`.
|
|
191
|
+
* @note A return value of 0 denotes a valid but empty frame. Skippable frames also report 0.
|
|
192
|
+
* @note The decompressed size field is optional. When it is absent (the function returns @c ZSTD_CONTENTSIZE_UNKNOWN),
|
|
193
|
+
* the caller must rely on streaming decompression or an application-specific upper bound. `ZSTD_decompress()`
|
|
194
|
+
* only requires an upper bound, so applications may enforce their own block limits (for example 16 KB).
|
|
195
|
+
* @note The decompressed size is guaranteed to be present when compression was performed with single-pass APIs such as
|
|
196
|
+
* `ZSTD_compress()`, `ZSTD_compressCCtx()`, `ZSTD_compress_usingDict()`, or `ZSTD_compress_usingCDict()`.
|
|
197
|
+
* @note The decompressed size is a 64-bit value and may exceed the addressable space of the system. Use streaming
|
|
198
|
+
* decompression when the value is too large to materialize in contiguous memory.
|
|
199
|
+
* @warning When processing untrusted input, validate the returned size against the application's limits; attackers may
|
|
200
|
+
* forge an arbitrarily large value.
|
|
201
|
+
* @note This function replaces `ZSTD_getDecompressedSize()`.
|
|
202
|
+
*/
|
|
203
203
|
#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
|
|
204
204
|
#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
|
|
205
205
|
ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
|
|
@@ -226,6 +226,28 @@ ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t
|
|
|
226
226
|
* which is always equal to its content size + 8 bytes for headers. */
|
|
227
227
|
ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
|
|
228
228
|
|
|
229
|
+
typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_FrameType_e;
|
|
230
|
+
#define ZSTD_frameType_e ZSTD_FrameType_e /* old name */
|
|
231
|
+
typedef struct {
|
|
232
|
+
unsigned long long frameContentSize; /**< if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
|
|
233
|
+
unsigned long long windowSize; /**< can be very large, up to <= frameContentSize */
|
|
234
|
+
unsigned blockSizeMax;
|
|
235
|
+
ZSTD_FrameType_e frameType; /**< if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
|
|
236
|
+
unsigned headerSize;
|
|
237
|
+
unsigned dictID; /**< for ZSTD_skippableFrame, contains the skippable magic variant [0-15] */
|
|
238
|
+
unsigned checksumFlag;
|
|
239
|
+
unsigned _reserved1;
|
|
240
|
+
unsigned _reserved2;
|
|
241
|
+
} ZSTD_FrameHeader;
|
|
242
|
+
#define ZSTD_frameHeader ZSTD_FrameHeader /* old name */
|
|
243
|
+
|
|
244
|
+
/*! ZSTD_getFrameHeader() : Requires v1.6.0+
|
|
245
|
+
* decode Frame Header into `zfhPtr`, or requires larger `srcSize`.
|
|
246
|
+
* @return : 0 => header is complete, `zfhPtr` is correctly filled,
|
|
247
|
+
* >0 => `srcSize` is too small, @return value is the wanted `srcSize` amount, `zfhPtr` is not filled,
|
|
248
|
+
* or an error code, which can be tested using ZSTD_isError() */
|
|
249
|
+
ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize);
|
|
250
|
+
|
|
229
251
|
|
|
230
252
|
/*====== Compression helper functions ======*/
|
|
231
253
|
|
|
@@ -308,6 +330,9 @@ ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer *
|
|
|
308
330
|
* Same as ZSTD_decompress(),
|
|
309
331
|
* requires an allocated ZSTD_DCtx.
|
|
310
332
|
* Compatible with sticky parameters (see below).
|
|
333
|
+
* The streaming session of @dctx is reset first, as with
|
|
334
|
+
* ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only).
|
|
335
|
+
* See ZSTD_DCtx_refPrefix() for the effect on a referenced prefix.
|
|
311
336
|
*/
|
|
312
337
|
ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
|
|
313
338
|
void* dst, size_t dstCapacity,
|
|
@@ -597,6 +622,7 @@ typedef enum {
|
|
|
597
622
|
* - The session : will stop compressing current frame, and make CCtx ready to start a new one.
|
|
598
623
|
* Useful after an error, or to interrupt any ongoing compression.
|
|
599
624
|
* Any internal data not yet flushed is cancelled.
|
|
625
|
+
* With nbWorkers >= 1, it waits for the jobs already started to complete.
|
|
600
626
|
* Compression parameters and dictionary remain unchanged.
|
|
601
627
|
* They will be used to compress next frame.
|
|
602
628
|
* Resetting session never fails.
|
|
@@ -688,7 +714,11 @@ ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param
|
|
|
688
714
|
/*! ZSTD_DCtx_reset() :
|
|
689
715
|
* Return a DCtx to clean state.
|
|
690
716
|
* Session and parameters can be reset jointly or separately.
|
|
691
|
-
*
|
|
717
|
+
* ZSTD_reset_parameters can only be used when no frame is being decompressed;
|
|
718
|
+
* otherwise it returns ZSTD_error_stage_wrong without resetting the parameters.
|
|
719
|
+
* ZSTD_reset_session_and_parameters also abandons any active frame.
|
|
720
|
+
* A successful parameter reset discards any referenced prefix or dictionary.
|
|
721
|
+
* See ZSTD_DCtx_refPrefix() for the effect of a session-only reset on a prefix.
|
|
692
722
|
* @return : 0, or an error code, which can be tested with ZSTD_isError()
|
|
693
723
|
*/
|
|
694
724
|
ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset);
|
|
@@ -942,8 +972,11 @@ ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
|
|
|
942
972
|
* Note: when an operation returns with an error code, the @zds state may be left in undefined state.
|
|
943
973
|
* It's UB to invoke `ZSTD_decompressStream()` on such a state.
|
|
944
974
|
* In order to re-use such a state, it must be first reset,
|
|
945
|
-
* which can be done explicitly (`ZSTD_DCtx_reset()`),
|
|
946
|
-
* or is implied for operations starting some new decompression job
|
|
975
|
+
* which can be done explicitly (`ZSTD_DCtx_reset(zds, ZSTD_reset_session_only)`),
|
|
976
|
+
* or is implied for operations starting some new decompression job
|
|
977
|
+
* (`ZSTD_initDStream()`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`, `ZSTD_decompress_usingDDict()`).
|
|
978
|
+
* The single-shot functions also leave the session clean:
|
|
979
|
+
* streaming can start a new frame afterwards without an explicit reset.
|
|
947
980
|
*/
|
|
948
981
|
ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
|
|
949
982
|
|
|
@@ -972,7 +1005,9 @@ ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
|
|
|
972
1005
|
* Dictionary must be identical to the one used during compression.
|
|
973
1006
|
* Note : This function loads the dictionary, resulting in significant startup delay.
|
|
974
1007
|
* It's intended for a dictionary used only once.
|
|
975
|
-
* Note : When `dict == NULL || dictSize < 8` no dictionary is used.
|
|
1008
|
+
* Note : When `dict == NULL || dictSize < 8` no dictionary is used.
|
|
1009
|
+
* Note : The streaming session of @dctx is reset first, as with
|
|
1010
|
+
* ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only). */
|
|
976
1011
|
ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
|
|
977
1012
|
void* dst, size_t dstCapacity,
|
|
978
1013
|
const void* src, size_t srcSize,
|
|
@@ -1022,6 +1057,13 @@ typedef struct ZSTD_DDict_s ZSTD_DDict;
|
|
|
1022
1057
|
* dictBuffer can be released after DDict creation, as its content is copied inside DDict. */
|
|
1023
1058
|
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
|
|
1024
1059
|
|
|
1060
|
+
/*! ZSTD_createDDict_byReference() : Requires v1.6.0+
|
|
1061
|
+
* Create a digested dictionary, ready to start decompression operation without startup delay.
|
|
1062
|
+
* Dictionary content is referenced, and therefore stays in dictBuffer.
|
|
1063
|
+
* It is important that dictBuffer outlives DDict,
|
|
1064
|
+
* it must remain read accessible throughout the lifetime of DDict */
|
|
1065
|
+
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
|
|
1066
|
+
|
|
1025
1067
|
/*! ZSTD_freeDDict() :
|
|
1026
1068
|
* Function frees memory allocated with ZSTD_createDDict()
|
|
1027
1069
|
* If a NULL pointer is passed, no operation is performed. */
|
|
@@ -1029,7 +1071,10 @@ ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
|
|
|
1029
1071
|
|
|
1030
1072
|
/*! ZSTD_decompress_usingDDict() :
|
|
1031
1073
|
* Decompression using a digested Dictionary.
|
|
1032
|
-
* Recommended when same dictionary is used multiple times.
|
|
1074
|
+
* Recommended when same dictionary is used multiple times.
|
|
1075
|
+
* Uses the supplied DDict, regardless of dictionaries referenced in dctx.
|
|
1076
|
+
* The streaming session of @dctx is reset first, as with
|
|
1077
|
+
* ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only). */
|
|
1033
1078
|
ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
|
|
1034
1079
|
void* dst, size_t dstCapacity,
|
|
1035
1080
|
const void* src, size_t srcSize,
|
|
@@ -1107,6 +1152,23 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
|
|
|
1107
1152
|
*/
|
|
1108
1153
|
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
|
|
1109
1154
|
|
|
1155
|
+
typedef enum {
|
|
1156
|
+
ZSTD_dct_auto = 0, /**< dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
|
|
1157
|
+
ZSTD_dct_rawContent = 1, /**< ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
|
|
1158
|
+
ZSTD_dct_fullDict = 2 /**< refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */
|
|
1159
|
+
} ZSTD_dictContentType_e;
|
|
1160
|
+
|
|
1161
|
+
typedef enum {
|
|
1162
|
+
ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */
|
|
1163
|
+
ZSTD_dlm_byRef = 1 /**< Reference dictionary content -- the dictionary buffer must outlive its users. */
|
|
1164
|
+
} ZSTD_dictLoadMethod_e;
|
|
1165
|
+
|
|
1166
|
+
/*! ZSTD_CCtx_loadDictionary_advanced() : Requires v1.6.0+
|
|
1167
|
+
* Same as ZSTD_CCtx_loadDictionary(), but gives finer control over
|
|
1168
|
+
* how to load the dictionary (by copy ? by reference ?)
|
|
1169
|
+
* and how to interpret it (automatic ? force raw mode ? full mode only ?) */
|
|
1170
|
+
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
|
|
1171
|
+
|
|
1110
1172
|
/*! ZSTD_CCtx_refCDict() : Requires v1.4.0+
|
|
1111
1173
|
* Reference a prepared dictionary, to be used for all future compressed frames.
|
|
1112
1174
|
* Note that compression parameters are enforced from within CDict,
|
|
@@ -1150,6 +1212,8 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
|
|
|
1150
1212
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
|
1151
1213
|
* Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary,
|
|
1152
1214
|
* meaning "return to no-dictionary mode".
|
|
1215
|
+
* Loading any dictionary also discards the multiple-DDict reference table,
|
|
1216
|
+
* without disabling ZSTD_d_refMultipleDDicts.
|
|
1153
1217
|
* Note 1 : Loading a dictionary involves building tables,
|
|
1154
1218
|
* which has a non-negligible impact on CPU usage and latency.
|
|
1155
1219
|
* It's recommended to "load once, use many times", to amortize the cost
|
|
@@ -1160,15 +1224,29 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
|
|
|
1160
1224
|
*/
|
|
1161
1225
|
ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
|
|
1162
1226
|
|
|
1227
|
+
/*! ZSTD_DCtx_loadDictionary_advanced() : Requires v1.6.0+
|
|
1228
|
+
* Same as ZSTD_DCtx_loadDictionary(),
|
|
1229
|
+
* but gives direct control over
|
|
1230
|
+
* how to load the dictionary (by copy ? by reference ?)
|
|
1231
|
+
* and how to interpret it (automatic ? force raw mode ? full mode only ?). */
|
|
1232
|
+
ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
|
|
1233
|
+
|
|
1163
1234
|
/*! ZSTD_DCtx_refDDict() : Requires v1.4.0+
|
|
1164
1235
|
* Reference a prepared dictionary, to be used to decompress next frames.
|
|
1165
|
-
*
|
|
1236
|
+
* In single-DDict mode, the dictionary remains active for decompression of
|
|
1237
|
+
* future frames using the same DCtx.
|
|
1166
1238
|
*
|
|
1167
1239
|
* If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function
|
|
1168
1240
|
* will store the DDict references in a table, and the DDict used for decompression
|
|
1169
1241
|
* will be determined at decompression time, as per the dict ID in the frame.
|
|
1170
|
-
* The memory for the table is allocated on the first call to refDDict
|
|
1171
|
-
* freed
|
|
1242
|
+
* The memory for the table is allocated on the first call to refDDict.
|
|
1243
|
+
* The table is freed by ZSTD_DCtx_refDDict(dctx, NULL), by ZSTD_DCtx_reset()
|
|
1244
|
+
* with ZSTD_reset_parameters or ZSTD_reset_session_and_parameters, by any
|
|
1245
|
+
* ZSTD_DCtx_loadDictionary() or ZSTD_DCtx_refPrefix() call, by disabling
|
|
1246
|
+
* multiple-DDict mode, and by ZSTD_freeDCtx().
|
|
1247
|
+
* Disabling multiple-DDict mode releases all dictionary references from the set;
|
|
1248
|
+
* no dictionary from the set is retained for subsequent decompression.
|
|
1249
|
+
* Referencing a DDict invalidates any previously loaded dictionary or prefix.
|
|
1172
1250
|
*
|
|
1173
1251
|
* If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary
|
|
1174
1252
|
* will be managed, and referencing a dictionary effectively "discards" any previous one.
|
|
@@ -1180,18 +1258,40 @@ ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, s
|
|
|
1180
1258
|
ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
|
|
1181
1259
|
|
|
1182
1260
|
/*! ZSTD_DCtx_refPrefix() : Requires v1.4.0+
|
|
1183
|
-
* Reference a prefix (single-usage dictionary)
|
|
1261
|
+
* Reference a prefix (single-usage dictionary) for decompression.
|
|
1184
1262
|
* This is the reverse operation of ZSTD_CCtx_refPrefix(),
|
|
1185
1263
|
* and must use the same prefix as the one used during compression.
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1264
|
+
* The prefix is **only used once**:
|
|
1265
|
+
* - ZSTD_decompressDCtx() uses it for exactly one call, including all frames
|
|
1266
|
+
* in concatenated input. The call consumes the prefix even if the input
|
|
1267
|
+
* is empty, contains only skippable frames, or produces an error.
|
|
1268
|
+
* - ZSTD_decompressStream() uses it until the first frame is completely
|
|
1269
|
+
* decoded and flushed, as indicated by a return value of 0. This includes
|
|
1270
|
+
* empty and skippable frames, even though they produce no output.
|
|
1271
|
+
* The explicit-dictionary functions ZSTD_decompress_usingDict() and
|
|
1272
|
+
* ZSTD_decompress_usingDDict() use their dictionary argument instead and
|
|
1273
|
+
* do not consume the prefix configured on the DCtx.
|
|
1274
|
+
*
|
|
1275
|
+
* ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only) preserves an unused prefix
|
|
1276
|
+
* if streaming decompression has not started. Once streaming has started,
|
|
1277
|
+
* even with an incomplete header, a session-only reset abandons the frame
|
|
1278
|
+
* and discards the prefix. After a streaming error the DCtx may be in an
|
|
1279
|
+
* undefined state and must be reset before streaming can resume. Errors
|
|
1280
|
+
* returned before streaming starts may leave an unused prefix installed.
|
|
1281
|
+
* To unconditionally discard it, use ZSTD_reset_session_and_parameters,
|
|
1282
|
+
* or ZSTD_reset_parameters when no frame is active. The latter can fail
|
|
1283
|
+
* with ZSTD_error_stage_wrong during decompression.
|
|
1188
1284
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
|
1189
|
-
* Note 1 : Adding any prefix (including NULL
|
|
1285
|
+
* Note 1 : Adding any prefix (including NULL or a zero-sized prefix) invalidates
|
|
1286
|
+
* any previously set prefix or dictionary,
|
|
1287
|
+
* including the multiple-DDict reference table.
|
|
1288
|
+
* Successfully loading or referencing another dictionary, or calling
|
|
1289
|
+
* ZSTD_initDStream(), also discards the prefix.
|
|
1190
1290
|
* Note 2 : Prefix buffer is referenced. It **must** outlive decompression.
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1291
|
+
* It must remain unmodified until the one-shot call returns, the
|
|
1292
|
+
* streaming frame completes, or the prefix is explicitly discarded.
|
|
1193
1293
|
* Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent).
|
|
1194
|
-
* Use
|
|
1294
|
+
* Use ZSTD_DCtx_refPrefix_advanced() to alter dictMode (Experimental section)
|
|
1195
1295
|
* Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost.
|
|
1196
1296
|
* A full dictionary is more costly, as it requires building tables.
|
|
1197
1297
|
*/
|
|
@@ -1370,17 +1470,6 @@ typedef struct {
|
|
|
1370
1470
|
ZSTD_frameParameters fParams;
|
|
1371
1471
|
} ZSTD_parameters;
|
|
1372
1472
|
|
|
1373
|
-
typedef enum {
|
|
1374
|
-
ZSTD_dct_auto = 0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
|
|
1375
|
-
ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
|
|
1376
|
-
ZSTD_dct_fullDict = 2 /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */
|
|
1377
|
-
} ZSTD_dictContentType_e;
|
|
1378
|
-
|
|
1379
|
-
typedef enum {
|
|
1380
|
-
ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */
|
|
1381
|
-
ZSTD_dlm_byRef = 1 /**< Reference dictionary content -- the dictionary buffer must outlive its users. */
|
|
1382
|
-
} ZSTD_dictLoadMethod_e;
|
|
1383
|
-
|
|
1384
1473
|
typedef enum {
|
|
1385
1474
|
ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */
|
|
1386
1475
|
ZSTD_f_zstd1_magicless = 1 /* Variant of zstd frame format, without initial 4-bytes magic number.
|
|
@@ -1493,9 +1582,10 @@ ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize(const void* src,
|
|
|
1493
1582
|
* @return : - upper-bound for the decompressed size of all data in all successive frames
|
|
1494
1583
|
* - if an error occurred: ZSTD_CONTENTSIZE_ERROR
|
|
1495
1584
|
*
|
|
1496
|
-
* note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame
|
|
1585
|
+
* note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame,
|
|
1586
|
+
* or the bound exceeds the largest returnable value, ZSTD_CONTENTSIZE_ERROR - 1.
|
|
1497
1587
|
* note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`.
|
|
1498
|
-
*
|
|
1588
|
+
* When this exact size is representable, `ZSTD_findDecompressedSize` and `ZSTD_decompressBound` return the same value.
|
|
1499
1589
|
* note 3 : when the decompressed size field isn't available, the upper-bound for that frame is calculated by:
|
|
1500
1590
|
* upper-bound = # blocks * min(128 KB, Window_Size)
|
|
1501
1591
|
*/
|
|
@@ -1507,27 +1597,6 @@ ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound(const void* src, size
|
|
|
1507
1597
|
* or an error code (if srcSize is too small) */
|
|
1508
1598
|
ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
|
|
1509
1599
|
|
|
1510
|
-
typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_FrameType_e;
|
|
1511
|
-
#define ZSTD_frameType_e ZSTD_FrameType_e /* old name */
|
|
1512
|
-
typedef struct {
|
|
1513
|
-
unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
|
|
1514
|
-
unsigned long long windowSize; /* can be very large, up to <= frameContentSize */
|
|
1515
|
-
unsigned blockSizeMax;
|
|
1516
|
-
ZSTD_FrameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
|
|
1517
|
-
unsigned headerSize;
|
|
1518
|
-
unsigned dictID; /* for ZSTD_skippableFrame, contains the skippable magic variant [0-15] */
|
|
1519
|
-
unsigned checksumFlag;
|
|
1520
|
-
unsigned _reserved1;
|
|
1521
|
-
unsigned _reserved2;
|
|
1522
|
-
} ZSTD_FrameHeader;
|
|
1523
|
-
#define ZSTD_frameHeader ZSTD_FrameHeader /* old name */
|
|
1524
|
-
|
|
1525
|
-
/*! ZSTD_getFrameHeader() :
|
|
1526
|
-
* decode Frame Header into `zfhPtr`, or requires larger `srcSize`.
|
|
1527
|
-
* @return : 0 => header is complete, `zfhPtr` is correctly filled,
|
|
1528
|
-
* >0 => `srcSize` is too small, @return value is the wanted `srcSize` amount, `zfhPtr` is not filled,
|
|
1529
|
-
* or an error code, which can be tested using ZSTD_isError() */
|
|
1530
|
-
ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize);
|
|
1531
1600
|
/*! ZSTD_getFrameHeader_advanced() :
|
|
1532
1601
|
* same as ZSTD_getFrameHeader(),
|
|
1533
1602
|
* with added capability to select a format (like ZSTD_f_zstd1_magicless) */
|
|
@@ -1699,6 +1768,8 @@ ZSTD_compressSequences(ZSTD_CCtx* cctx,
|
|
|
1699
1768
|
* - @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals.
|
|
1700
1769
|
* @litBufCapacity must be at least 8 bytes larger than @litSize.
|
|
1701
1770
|
* - @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error.
|
|
1771
|
+
* - Each block must regenerate at most ZSTD_BLOCKSIZE_MAX bytes, or less with a smaller window or ZSTD_c_maxBlockSize.
|
|
1772
|
+
* A larger block will generate an error.
|
|
1702
1773
|
* @return : final compressed size, or a ZSTD error code.
|
|
1703
1774
|
*/
|
|
1704
1775
|
ZSTDLIB_STATIC_API size_t
|
|
@@ -1813,6 +1884,8 @@ ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, si
|
|
|
1813
1884
|
/*! ZSTD_estimate?DictSize() :
|
|
1814
1885
|
* ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict().
|
|
1815
1886
|
* ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced().
|
|
1887
|
+
* These estimates return an error code if dictSize is too large.
|
|
1888
|
+
* Check the result with ZSTD_isError().
|
|
1816
1889
|
* Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller.
|
|
1817
1890
|
*/
|
|
1818
1891
|
ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
|
|
@@ -1836,7 +1909,10 @@ ZSTDLIB_STATIC_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadM
|
|
|
1836
1909
|
* Note 3 : cParams : use ZSTD_getCParams() to convert a compression level
|
|
1837
1910
|
* into its associated cParams.
|
|
1838
1911
|
* Limitation 1 : currently not compatible with internal dictionary creation, triggered by
|
|
1839
|
-
* ZSTD_CCtx_loadDictionary(),
|
|
1912
|
+
* ZSTD_CCtx_loadDictionary(), ZSTD_DCtx_loadDictionary(), ZSTD_DCtx_refPrefix(),
|
|
1913
|
+
* ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict().
|
|
1914
|
+
* For one-shot decompression, ZSTD_decompress_usingDict() needs no allocation.
|
|
1915
|
+
* Otherwise, use ZSTD_initStaticDDict() + ZSTD_DCtx_refDDict().
|
|
1840
1916
|
* Limitation 2 : static cctx currently not compatible with multi-threading.
|
|
1841
1917
|
* Limitation 3 : static dctx is incompatible with legacy support.
|
|
1842
1918
|
*/
|
|
@@ -1868,15 +1944,14 @@ ZSTDLIB_STATIC_API const ZSTD_DDict* ZSTD_initStaticDDict(
|
|
|
1868
1944
|
typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
|
|
1869
1945
|
typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
|
|
1870
1946
|
typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
|
|
1871
|
-
static
|
|
1872
|
-
#ifdef __GNUC__
|
|
1873
|
-
__attribute__((__unused__))
|
|
1874
|
-
#endif
|
|
1875
|
-
|
|
1876
1947
|
#if defined(__clang__) && __clang_major__ >= 5
|
|
1877
1948
|
#pragma clang diagnostic push
|
|
1878
1949
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
|
1879
1950
|
#endif
|
|
1951
|
+
static
|
|
1952
|
+
#ifdef __GNUC__
|
|
1953
|
+
__attribute__((__unused__))
|
|
1954
|
+
#endif
|
|
1880
1955
|
ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
|
|
1881
1956
|
#if defined(__clang__) && __clang_major__ >= 5
|
|
1882
1957
|
#pragma clang diagnostic pop
|
|
@@ -1898,9 +1973,10 @@ ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_
|
|
|
1898
1973
|
* This can limit resources for applications with multiple threads where each one uses
|
|
1899
1974
|
* a threaded compression mode (via ZSTD_c_nbWorkers parameter).
|
|
1900
1975
|
* ZSTD_createThreadPool creates a new thread pool with a given number of threads.
|
|
1976
|
+
* ZSTD_c_nbWorkers does not change the number of threads of such a pool.
|
|
1901
1977
|
* Note that the lifetime of such pool must exist while being used.
|
|
1902
1978
|
* ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value
|
|
1903
|
-
* to use an internal thread pool).
|
|
1979
|
+
* to use an internal thread pool). The context then no longer uses its previous pool.
|
|
1904
1980
|
* ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer.
|
|
1905
1981
|
*/
|
|
1906
1982
|
typedef struct POOL_ctx_s ZSTD_threadPool;
|
|
@@ -2012,12 +2088,6 @@ size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
|
|
|
2012
2088
|
* It saves some memory, but also requires that `dict` outlives its usage within `cctx` */
|
|
2013
2089
|
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
|
|
2014
2090
|
|
|
2015
|
-
/*! ZSTD_CCtx_loadDictionary_advanced() :
|
|
2016
|
-
* Same as ZSTD_CCtx_loadDictionary(), but gives finer control over
|
|
2017
|
-
* how to load the dictionary (by copy ? by reference ?)
|
|
2018
|
-
* and how to interpret it (automatic ? force raw mode ? full mode only ?) */
|
|
2019
|
-
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
|
|
2020
|
-
|
|
2021
2091
|
/*! ZSTD_CCtx_refPrefix_advanced() :
|
|
2022
2092
|
* Same as ZSTD_CCtx_refPrefix(), but gives finer control over
|
|
2023
2093
|
* how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */
|
|
@@ -2452,13 +2522,6 @@ ZSTDLIB_STATIC_API size_t ZSTD_compressStream2_simpleArgs (
|
|
|
2452
2522
|
* Note 3 : Skippable Frame Identifiers are considered valid. */
|
|
2453
2523
|
ZSTDLIB_STATIC_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
|
|
2454
2524
|
|
|
2455
|
-
/*! ZSTD_createDDict_byReference() :
|
|
2456
|
-
* Create a digested dictionary, ready to start decompression operation without startup delay.
|
|
2457
|
-
* Dictionary content is referenced, and therefore stays in dictBuffer.
|
|
2458
|
-
* It is important that dictBuffer outlives DDict,
|
|
2459
|
-
* it must remain read accessible throughout the lifetime of DDict */
|
|
2460
|
-
ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
|
|
2461
|
-
|
|
2462
2525
|
/*! ZSTD_DCtx_loadDictionary_byReference() :
|
|
2463
2526
|
* Same as ZSTD_DCtx_loadDictionary(),
|
|
2464
2527
|
* but references `dict` content instead of copying it into `dctx`.
|
|
@@ -2466,16 +2529,11 @@ ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuff
|
|
|
2466
2529
|
* However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. */
|
|
2467
2530
|
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
|
|
2468
2531
|
|
|
2469
|
-
/*! ZSTD_DCtx_loadDictionary_advanced() :
|
|
2470
|
-
* Same as ZSTD_DCtx_loadDictionary(),
|
|
2471
|
-
* but gives direct control over
|
|
2472
|
-
* how to load the dictionary (by copy ? by reference ?)
|
|
2473
|
-
* and how to interpret it (automatic ? force raw mode ? full mode only ?). */
|
|
2474
|
-
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
|
|
2475
|
-
|
|
2476
2532
|
/*! ZSTD_DCtx_refPrefix_advanced() :
|
|
2477
2533
|
* Same as ZSTD_DCtx_refPrefix(), but gives finer control over
|
|
2478
|
-
* how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?)
|
|
2534
|
+
* how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?).
|
|
2535
|
+
* The prefix has the same single-use lifetime and reset behavior described
|
|
2536
|
+
* by ZSTD_DCtx_refPrefix(). */
|
|
2479
2537
|
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
|
|
2480
2538
|
|
|
2481
2539
|
/*! ZSTD_DCtx_setMaxWindowSize() :
|
|
@@ -2550,7 +2608,22 @@ ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParamete
|
|
|
2550
2608
|
* to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict()
|
|
2551
2609
|
* using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead
|
|
2552
2610
|
* store all references. At decompression time, the appropriate dictID is selected
|
|
2553
|
-
* from the set of DDicts based on the dictID in
|
|
2611
|
+
* from the set of DDicts based on the dictID in each frame. This applies to
|
|
2612
|
+
* ZSTD_decompressDCtx() and ZSTD_decompressStream(); entry points taking an
|
|
2613
|
+
* explicit dictionary use that dictionary instead.
|
|
2614
|
+
* When a set exists, an ordinary Zstandard frame with a nonzero dictionary ID must
|
|
2615
|
+
* have an exact match in the set; otherwise decompression returns
|
|
2616
|
+
* ZSTD_error_dictionary_wrong. A frame with dictionary ID 0 (including an omitted
|
|
2617
|
+
* ID) uses the registered ID-0 DDict if present, or no dictionary otherwise.
|
|
2618
|
+
* There is no default dictionary in the set, and a lookup does not change the
|
|
2619
|
+
* dictionary used by another frame.
|
|
2620
|
+
* Skippable frames do not select a dictionary. Legacy formats are not supported
|
|
2621
|
+
* by set-based decoding; use a single or explicitly supplied dictionary instead.
|
|
2622
|
+
* Loading a dictionary or referencing a prefix discards the referenced set,
|
|
2623
|
+
* without disabling this mode. Referencing a DDict discards any previously
|
|
2624
|
+
* loaded dictionary or prefix. The two kinds of dictionary storage cannot coexist.
|
|
2625
|
+
* Disabling this mode discards the entire set. No dictionary from the set is
|
|
2626
|
+
* retained for subsequent decompression.
|
|
2554
2627
|
*
|
|
2555
2628
|
* Usage is simply calling ZSTD_refDDict() on multiple dict buffers.
|
|
2556
2629
|
*
|
|
@@ -3030,10 +3103,6 @@ ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const vo
|
|
|
3030
3103
|
ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.")
|
|
3031
3104
|
ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
|
|
3032
3105
|
|
|
3033
|
-
ZSTD_DEPRECATED("This function will likely be removed in a future release. It is misleading and has very limited utility.")
|
|
3034
|
-
ZSTDLIB_STATIC_API
|
|
3035
|
-
size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */
|
|
3036
|
-
|
|
3037
3106
|
ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.")
|
|
3038
3107
|
ZSTDLIB_STATIC_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
|
3039
3108
|
ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.")
|
|
@@ -3090,8 +3159,12 @@ size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_
|
|
|
3090
3159
|
as long as the encoder and decoder progress in "lock-step",
|
|
3091
3160
|
aka use exactly the same buffer sizes, break contiguity at the same place, etc.
|
|
3092
3161
|
|
|
3093
|
-
Once buffers are
|
|
3162
|
+
Once buffers are set up and decompression parameters are configured, initialize the decoder with ZSTD_decompressBegin().
|
|
3094
3163
|
If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict().
|
|
3164
|
+
One of these initialization functions must be called before the first ZSTD_decompressContinue() call for every frame,
|
|
3165
|
+
including when reusing a context or after calling ZSTD_DCtx_reset().
|
|
3166
|
+
ZSTD_DCtx_reset() does not replace this initialization, and ZSTD_decompressContinue() does not initialize the decoder itself.
|
|
3167
|
+
After a session reset, an interrupted frame cannot be resumed : initialize the decoder again and restart from the frame's beginning.
|
|
3095
3168
|
|
|
3096
3169
|
Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively.
|
|
3097
3170
|
ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue().
|
|
@@ -3102,7 +3175,7 @@ size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_
|
|
|
3102
3175
|
It can also be an error code, which can be tested with ZSTD_isError().
|
|
3103
3176
|
|
|
3104
3177
|
A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero.
|
|
3105
|
-
|
|
3178
|
+
Before decoding another frame, call the appropriate ZSTD_decompressBegin*() function again.
|
|
3106
3179
|
|
|
3107
3180
|
Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType().
|
|
3108
3181
|
This information is not required to properly decode a frame.
|
|
@@ -3123,21 +3196,45 @@ size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_
|
|
|
3123
3196
|
|
|
3124
3197
|
ZSTDLIB_STATIC_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
|
|
3125
3198
|
|
|
3199
|
+
/*! ZSTD_decompressBegin() :
|
|
3200
|
+
* Initialize the bufferless decoder to start a new frame without a dictionary.
|
|
3201
|
+
* Decompression parameters must be configured before calling this function.
|
|
3202
|
+
* Call this function, ZSTD_decompressBegin_usingDict(), or ZSTD_decompressBegin_usingDDict()
|
|
3203
|
+
* before the first ZSTD_decompressContinue() call for each frame, including after ZSTD_DCtx_reset().
|
|
3204
|
+
* Use the dictionary-taking variants when the frame requires a dictionary.
|
|
3205
|
+
*/
|
|
3126
3206
|
ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
|
|
3127
3207
|
ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
|
|
3128
3208
|
ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
|
|
3129
3209
|
|
|
3130
3210
|
ZSTDLIB_STATIC_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
|
|
3211
|
+
|
|
3212
|
+
/*! ZSTD_decompressContinue() :
|
|
3213
|
+
* Decode the next part of a frame initialized with ZSTD_decompressBegin()
|
|
3214
|
+
* or one of its dictionary-taking variants. This function does not initialize the decoder.
|
|
3215
|
+
* After finishing a frame or resetting the session, initialize the decoder again
|
|
3216
|
+
* before calling this function for a new frame.
|
|
3217
|
+
*/
|
|
3131
3218
|
ZSTDLIB_STATIC_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
|
3132
3219
|
|
|
3133
3220
|
/* misc */
|
|
3134
|
-
ZSTD_DEPRECATED("This function will likely be removed in the next minor release. It is misleading and has very limited utility.")
|
|
3135
|
-
ZSTDLIB_STATIC_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
|
|
3136
3221
|
typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
|
|
3137
3222
|
ZSTDLIB_STATIC_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
|
|
3138
3223
|
|
|
3139
3224
|
|
|
3140
3225
|
|
|
3226
|
+
/*! ZSTD_isDeterministicBuild() :
|
|
3227
|
+
* Returns 1 if the library is built using standard compilation flags,
|
|
3228
|
+
* and participates in determinism guarantees with other builds of the
|
|
3229
|
+
* same version.
|
|
3230
|
+
* If this function returns 0, it means the library was compiled with
|
|
3231
|
+
* non-standard compilation flags that change the output of the
|
|
3232
|
+
* compressor.
|
|
3233
|
+
* This is mainly used for Zstd's determinism test suite, which is only
|
|
3234
|
+
* run when this function returns 1.
|
|
3235
|
+
*/
|
|
3236
|
+
ZSTDLIB_API int ZSTD_isDeterministicBuild(void);
|
|
3237
|
+
|
|
3141
3238
|
|
|
3142
3239
|
/* ========================================= */
|
|
3143
3240
|
/** Block level API (DEPRECATED) */
|
data/multi_compress.gemspec
CHANGED
|
@@ -25,6 +25,8 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
"exe/*",
|
|
26
26
|
"docs/**/*.md",
|
|
27
27
|
"ext/**/*.{c,h,rb}",
|
|
28
|
+
"ext/multi_compress/exports.darwin",
|
|
29
|
+
"ext/multi_compress/exports.map",
|
|
28
30
|
"ext/multi_compress/vendor/**/*",
|
|
29
31
|
"ext/multi_compress/vendor/.vendored",
|
|
30
32
|
"db_core/**/*.{c,h}",
|
data/mysql_udf/Makefile
CHANGED
|
@@ -21,6 +21,13 @@ WARNFLAGS ?= -Wall -Wextra -Werror
|
|
|
21
21
|
CFLAGS ?= -O2 -fPIC -std=c99 $(WARNFLAGS) -I$(ZSTD_DIR) -I$(CORE_DIR)/include
|
|
22
22
|
ZSTD_CFLAGS ?= -O2 -fPIC -std=c99 -I$(ZSTD_DIR) -I$(ZSTD_DIR)/common
|
|
23
23
|
|
|
24
|
+
ZSTD_PRIVATE_DEFS := -DZSTDLIB_VISIBLE= -DZSTDERRORLIB_VISIBLE= -DZDICTLIB_VISIBLE= -DZSTD_TRACE=0
|
|
25
|
+
ZSTD_PRIVATE_FLAGS := -fvisibility=hidden $(ZSTD_PRIVATE_DEFS)
|
|
26
|
+
UDF_EXPORT_MAP := $(CURDIR)/multi_compress_mysql.exports
|
|
27
|
+
ifeq ($(shell uname -s),Linux)
|
|
28
|
+
UDF_LDFLAGS := -Wl,--version-script=$(UDF_EXPORT_MAP)
|
|
29
|
+
endif
|
|
30
|
+
|
|
24
31
|
ZSTD_OBJ_DIR := $(BUILD)/zstd
|
|
25
32
|
ZSTD_C_SRCS := $(wildcard $(ZSTD_DIR)/common/*.c) $(wildcard $(ZSTD_DIR)/decompress/*.c)
|
|
26
33
|
ZSTD_C_OBJS := $(patsubst $(ZSTD_DIR)/%.c,$(ZSTD_OBJ_DIR)/%.o,$(ZSTD_C_SRCS))
|
|
@@ -48,7 +55,7 @@ $(BUILD):
|
|
|
48
55
|
|
|
49
56
|
$(ZSTD_OBJ_DIR)/%.o: $(ZSTD_DIR)/%.c
|
|
50
57
|
@mkdir -p $(dir $@)
|
|
51
|
-
$(CC) $(ZSTD_CFLAGS) -MMD -MP -c $< -o $@
|
|
58
|
+
$(CC) $(ZSTD_CFLAGS) $(ZSTD_PRIVATE_FLAGS) -MMD -MP -c $< -o $@
|
|
52
59
|
|
|
53
60
|
$(ZSTD_OBJ_DIR)/%.o: $(ZSTD_DIR)/%.S
|
|
54
61
|
@mkdir -p $(dir $@)
|
|
@@ -57,17 +64,17 @@ $(ZSTD_OBJ_DIR)/%.o: $(ZSTD_DIR)/%.S
|
|
|
57
64
|
$(ZSTD_LIB): $(ZSTD_OBJS) | $(BUILD)
|
|
58
65
|
$(AR) rcs $@ $^
|
|
59
66
|
|
|
60
|
-
$(UDF_SO): src/multi_compress_mysql.c $(CORE_DIR)/src/mcdb_format.c $(CORE_DIR)/include/mcdb_format.h $(ZSTD_LIB) | $(BUILD)
|
|
67
|
+
$(UDF_SO): src/multi_compress_mysql.c $(CORE_DIR)/src/mcdb_format.c $(CORE_DIR)/include/mcdb_format.h $(ZSTD_LIB) $(UDF_EXPORT_MAP) | $(BUILD)
|
|
61
68
|
@$(MYSQL_UDF_HEADER_CHECK)
|
|
62
|
-
$(CC) $(CFLAGS) $(MYSQL_UDF_CPPFLAGS) -shared \
|
|
69
|
+
$(CC) $(CFLAGS) $(ZSTD_PRIVATE_DEFS) $(MYSQL_UDF_CPPFLAGS) -shared \
|
|
63
70
|
src/multi_compress_mysql.c $(CORE_DIR)/src/mcdb_format.c $(ZSTD_LIB) \
|
|
64
|
-
-o $@
|
|
71
|
+
$(UDF_LDFLAGS) -o $@
|
|
65
72
|
@echo "built $@"
|
|
66
73
|
|
|
67
74
|
udf: $(UDF_SO)
|
|
68
75
|
|
|
69
76
|
$(CLI): $(CORE_DIR)/src/mcdb_format.c $(CORE_DIR)/include/mcdb_format.h test/mcdb_cli.c $(ZSTD_LIB) | $(BUILD)
|
|
70
|
-
$(CC) $(CFLAGS) $(CORE_DIR)/src/mcdb_format.c test/mcdb_cli.c $(ZSTD_LIB) -o $@
|
|
77
|
+
$(CC) $(CFLAGS) $(ZSTD_PRIVATE_DEFS) $(CORE_DIR)/src/mcdb_format.c test/mcdb_cli.c $(ZSTD_LIB) -o $@
|
|
71
78
|
|
|
72
79
|
fixtures:
|
|
73
80
|
RUBYLIB=../lib ruby $(FIXTURES)/generate.rb
|