extzstd 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -14
- data/contrib/zstd/CHANGELOG +301 -56
- data/contrib/zstd/CONTRIBUTING.md +169 -72
- data/contrib/zstd/LICENSE +4 -4
- data/contrib/zstd/Makefile +116 -87
- data/contrib/zstd/Package.swift +36 -0
- data/contrib/zstd/README.md +62 -32
- data/contrib/zstd/TESTING.md +2 -3
- data/contrib/zstd/appveyor.yml +52 -136
- data/contrib/zstd/lib/BUCK +5 -7
- data/contrib/zstd/lib/Makefile +225 -222
- data/contrib/zstd/lib/README.md +51 -6
- data/contrib/zstd/lib/common/allocations.h +55 -0
- data/contrib/zstd/lib/common/bits.h +200 -0
- data/contrib/zstd/lib/common/bitstream.h +45 -62
- data/contrib/zstd/lib/common/compiler.h +205 -22
- data/contrib/zstd/lib/common/cpu.h +1 -3
- data/contrib/zstd/lib/common/debug.c +1 -1
- data/contrib/zstd/lib/common/debug.h +12 -19
- data/contrib/zstd/lib/common/entropy_common.c +172 -48
- data/contrib/zstd/lib/common/error_private.c +10 -2
- data/contrib/zstd/lib/common/error_private.h +82 -3
- data/contrib/zstd/lib/common/fse.h +37 -86
- data/contrib/zstd/lib/common/fse_decompress.c +117 -92
- data/contrib/zstd/lib/common/huf.h +99 -166
- data/contrib/zstd/lib/common/mem.h +124 -142
- data/contrib/zstd/lib/common/pool.c +54 -27
- data/contrib/zstd/lib/common/pool.h +10 -4
- data/contrib/zstd/lib/common/portability_macros.h +156 -0
- data/contrib/zstd/lib/common/threading.c +74 -19
- data/contrib/zstd/lib/common/threading.h +5 -10
- data/contrib/zstd/lib/common/xxhash.c +7 -847
- data/contrib/zstd/lib/common/xxhash.h +5568 -167
- data/contrib/zstd/lib/common/zstd_common.c +2 -37
- data/contrib/zstd/lib/common/zstd_deps.h +111 -0
- data/contrib/zstd/lib/common/zstd_internal.h +132 -187
- data/contrib/zstd/lib/common/zstd_trace.h +163 -0
- data/contrib/zstd/lib/compress/clevels.h +134 -0
- data/contrib/zstd/lib/compress/fse_compress.c +83 -157
- data/contrib/zstd/lib/compress/hist.c +27 -29
- data/contrib/zstd/lib/compress/hist.h +2 -2
- data/contrib/zstd/lib/compress/huf_compress.c +916 -279
- data/contrib/zstd/lib/compress/zstd_compress.c +3773 -1019
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +610 -203
- data/contrib/zstd/lib/compress/zstd_compress_literals.c +119 -42
- data/contrib/zstd/lib/compress/zstd_compress_literals.h +16 -6
- data/contrib/zstd/lib/compress/zstd_compress_sequences.c +42 -19
- data/contrib/zstd/lib/compress/zstd_compress_sequences.h +1 -1
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +49 -317
- data/contrib/zstd/lib/compress/zstd_compress_superblock.h +1 -1
- data/contrib/zstd/lib/compress/zstd_cwksp.h +320 -103
- data/contrib/zstd/lib/compress/zstd_double_fast.c +388 -151
- data/contrib/zstd/lib/compress/zstd_double_fast.h +3 -2
- data/contrib/zstd/lib/compress/zstd_fast.c +729 -265
- data/contrib/zstd/lib/compress/zstd_fast.h +3 -2
- data/contrib/zstd/lib/compress/zstd_lazy.c +1270 -251
- data/contrib/zstd/lib/compress/zstd_lazy.h +61 -1
- data/contrib/zstd/lib/compress/zstd_ldm.c +324 -219
- data/contrib/zstd/lib/compress/zstd_ldm.h +9 -2
- data/contrib/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
- data/contrib/zstd/lib/compress/zstd_opt.c +481 -209
- data/contrib/zstd/lib/compress/zstd_opt.h +1 -1
- data/contrib/zstd/lib/compress/zstdmt_compress.c +181 -457
- data/contrib/zstd/lib/compress/zstdmt_compress.h +34 -113
- data/contrib/zstd/lib/decompress/huf_decompress.c +1199 -565
- data/contrib/zstd/lib/decompress/huf_decompress_amd64.S +576 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.c +12 -12
- data/contrib/zstd/lib/decompress/zstd_ddict.h +2 -2
- data/contrib/zstd/lib/decompress/zstd_decompress.c +627 -157
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1086 -326
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +19 -5
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +62 -13
- data/contrib/zstd/lib/deprecated/zbuff.h +1 -1
- data/contrib/zstd/lib/deprecated/zbuff_common.c +1 -1
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +24 -4
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +3 -1
- data/contrib/zstd/lib/dictBuilder/cover.c +73 -52
- data/contrib/zstd/lib/dictBuilder/cover.h +7 -6
- data/contrib/zstd/lib/dictBuilder/divsufsort.c +1 -1
- data/contrib/zstd/lib/dictBuilder/fastcover.c +44 -35
- data/contrib/zstd/lib/dictBuilder/zdict.c +103 -111
- data/contrib/zstd/lib/legacy/zstd_legacy.h +8 -1
- data/contrib/zstd/lib/legacy/zstd_v01.c +21 -54
- data/contrib/zstd/lib/legacy/zstd_v01.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v02.c +29 -70
- data/contrib/zstd/lib/legacy/zstd_v02.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v03.c +30 -73
- data/contrib/zstd/lib/legacy/zstd_v03.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v04.c +29 -71
- data/contrib/zstd/lib/legacy/zstd_v04.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v05.c +40 -86
- data/contrib/zstd/lib/legacy/zstd_v05.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v06.c +47 -88
- data/contrib/zstd/lib/legacy/zstd_v06.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v07.c +40 -83
- data/contrib/zstd/lib/legacy/zstd_v07.h +1 -1
- data/contrib/zstd/lib/libzstd.mk +214 -0
- data/contrib/zstd/lib/libzstd.pc.in +7 -6
- data/contrib/zstd/lib/module.modulemap +35 -0
- data/contrib/zstd/lib/{dictBuilder/zdict.h → zdict.h} +203 -34
- data/contrib/zstd/lib/zstd.h +1217 -287
- data/contrib/zstd/lib/{common/zstd_errors.h → zstd_errors.h} +28 -8
- data/ext/extconf.rb +7 -6
- data/ext/extzstd.c +19 -10
- data/ext/extzstd.h +6 -0
- data/ext/libzstd_conf.h +0 -1
- data/ext/zstd_decompress_asm.S +1 -0
- data/gemstub.rb +3 -21
- data/lib/extzstd/version.rb +6 -1
- data/lib/extzstd.rb +0 -2
- data/test/test_basic.rb +0 -5
- metadata +18 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
@@ -8,34 +8,184 @@
|
|
8
8
|
* You may select, at your option, one of the above-listed licenses.
|
9
9
|
*/
|
10
10
|
|
11
|
-
#ifndef DICTBUILDER_H_001
|
12
|
-
#define DICTBUILDER_H_001
|
13
|
-
|
14
11
|
#if defined (__cplusplus)
|
15
12
|
extern "C" {
|
16
13
|
#endif
|
17
14
|
|
15
|
+
#ifndef ZSTD_ZDICT_H
|
16
|
+
#define ZSTD_ZDICT_H
|
18
17
|
|
19
18
|
/*====== Dependencies ======*/
|
20
19
|
#include <stddef.h> /* size_t */
|
21
20
|
|
22
21
|
|
23
22
|
/* ===== ZDICTLIB_API : control library symbols visibility ===== */
|
24
|
-
#ifndef
|
25
|
-
|
26
|
-
#
|
23
|
+
#ifndef ZDICTLIB_VISIBLE
|
24
|
+
/* Backwards compatibility with old macro name */
|
25
|
+
# ifdef ZDICTLIB_VISIBILITY
|
26
|
+
# define ZDICTLIB_VISIBLE ZDICTLIB_VISIBILITY
|
27
|
+
# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
|
28
|
+
# define ZDICTLIB_VISIBLE __attribute__ ((visibility ("default")))
|
29
|
+
# else
|
30
|
+
# define ZDICTLIB_VISIBLE
|
31
|
+
# endif
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#ifndef ZDICTLIB_HIDDEN
|
35
|
+
# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
|
36
|
+
# define ZDICTLIB_HIDDEN __attribute__ ((visibility ("hidden")))
|
27
37
|
# else
|
28
|
-
# define
|
38
|
+
# define ZDICTLIB_HIDDEN
|
29
39
|
# endif
|
30
40
|
#endif
|
41
|
+
|
31
42
|
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
32
|
-
# define ZDICTLIB_API __declspec(dllexport)
|
43
|
+
# define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBLE
|
33
44
|
#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
|
34
|
-
# define ZDICTLIB_API __declspec(dllimport)
|
45
|
+
# define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
35
46
|
#else
|
36
|
-
# define ZDICTLIB_API
|
47
|
+
# define ZDICTLIB_API ZDICTLIB_VISIBLE
|
37
48
|
#endif
|
38
49
|
|
50
|
+
/*******************************************************************************
|
51
|
+
* Zstd dictionary builder
|
52
|
+
*
|
53
|
+
* FAQ
|
54
|
+
* ===
|
55
|
+
* Why should I use a dictionary?
|
56
|
+
* ------------------------------
|
57
|
+
*
|
58
|
+
* Zstd can use dictionaries to improve compression ratio of small data.
|
59
|
+
* Traditionally small files don't compress well because there is very little
|
60
|
+
* repetition in a single sample, since it is small. But, if you are compressing
|
61
|
+
* many similar files, like a bunch of JSON records that share the same
|
62
|
+
* structure, you can train a dictionary on ahead of time on some samples of
|
63
|
+
* these files. Then, zstd can use the dictionary to find repetitions that are
|
64
|
+
* present across samples. This can vastly improve compression ratio.
|
65
|
+
*
|
66
|
+
* When is a dictionary useful?
|
67
|
+
* ----------------------------
|
68
|
+
*
|
69
|
+
* Dictionaries are useful when compressing many small files that are similar.
|
70
|
+
* The larger a file is, the less benefit a dictionary will have. Generally,
|
71
|
+
* we don't expect dictionary compression to be effective past 100KB. And the
|
72
|
+
* smaller a file is, the more we would expect the dictionary to help.
|
73
|
+
*
|
74
|
+
* How do I use a dictionary?
|
75
|
+
* --------------------------
|
76
|
+
*
|
77
|
+
* Simply pass the dictionary to the zstd compressor with
|
78
|
+
* `ZSTD_CCtx_loadDictionary()`. The same dictionary must then be passed to
|
79
|
+
* the decompressor, using `ZSTD_DCtx_loadDictionary()`. There are other
|
80
|
+
* more advanced functions that allow selecting some options, see zstd.h for
|
81
|
+
* complete documentation.
|
82
|
+
*
|
83
|
+
* What is a zstd dictionary?
|
84
|
+
* --------------------------
|
85
|
+
*
|
86
|
+
* A zstd dictionary has two pieces: Its header, and its content. The header
|
87
|
+
* contains a magic number, the dictionary ID, and entropy tables. These
|
88
|
+
* entropy tables allow zstd to save on header costs in the compressed file,
|
89
|
+
* which really matters for small data. The content is just bytes, which are
|
90
|
+
* repeated content that is common across many samples.
|
91
|
+
*
|
92
|
+
* What is a raw content dictionary?
|
93
|
+
* ---------------------------------
|
94
|
+
*
|
95
|
+
* A raw content dictionary is just bytes. It doesn't have a zstd dictionary
|
96
|
+
* header, a dictionary ID, or entropy tables. Any buffer is a valid raw
|
97
|
+
* content dictionary.
|
98
|
+
*
|
99
|
+
* How do I train a dictionary?
|
100
|
+
* ----------------------------
|
101
|
+
*
|
102
|
+
* Gather samples from your use case. These samples should be similar to each
|
103
|
+
* other. If you have several use cases, you could try to train one dictionary
|
104
|
+
* per use case.
|
105
|
+
*
|
106
|
+
* Pass those samples to `ZDICT_trainFromBuffer()` and that will train your
|
107
|
+
* dictionary. There are a few advanced versions of this function, but this
|
108
|
+
* is a great starting point. If you want to further tune your dictionary
|
109
|
+
* you could try `ZDICT_optimizeTrainFromBuffer_cover()`. If that is too slow
|
110
|
+
* you can try `ZDICT_optimizeTrainFromBuffer_fastCover()`.
|
111
|
+
*
|
112
|
+
* If the dictionary training function fails, that is likely because you
|
113
|
+
* either passed too few samples, or a dictionary would not be effective
|
114
|
+
* for your data. Look at the messages that the dictionary trainer printed,
|
115
|
+
* if it doesn't say too few samples, then a dictionary would not be effective.
|
116
|
+
*
|
117
|
+
* How large should my dictionary be?
|
118
|
+
* ----------------------------------
|
119
|
+
*
|
120
|
+
* A reasonable dictionary size, the `dictBufferCapacity`, is about 100KB.
|
121
|
+
* The zstd CLI defaults to a 110KB dictionary. You likely don't need a
|
122
|
+
* dictionary larger than that. But, most use cases can get away with a
|
123
|
+
* smaller dictionary. The advanced dictionary builders can automatically
|
124
|
+
* shrink the dictionary for you, and select the smallest size that doesn't
|
125
|
+
* hurt compression ratio too much. See the `shrinkDict` parameter.
|
126
|
+
* A smaller dictionary can save memory, and potentially speed up
|
127
|
+
* compression.
|
128
|
+
*
|
129
|
+
* How many samples should I provide to the dictionary builder?
|
130
|
+
* ------------------------------------------------------------
|
131
|
+
*
|
132
|
+
* We generally recommend passing ~100x the size of the dictionary
|
133
|
+
* in samples. A few thousand should suffice. Having too few samples
|
134
|
+
* can hurt the dictionaries effectiveness. Having more samples will
|
135
|
+
* only improve the dictionaries effectiveness. But having too many
|
136
|
+
* samples can slow down the dictionary builder.
|
137
|
+
*
|
138
|
+
* How do I determine if a dictionary will be effective?
|
139
|
+
* -----------------------------------------------------
|
140
|
+
*
|
141
|
+
* Simply train a dictionary and try it out. You can use zstd's built in
|
142
|
+
* benchmarking tool to test the dictionary effectiveness.
|
143
|
+
*
|
144
|
+
* # Benchmark levels 1-3 without a dictionary
|
145
|
+
* zstd -b1e3 -r /path/to/my/files
|
146
|
+
* # Benchmark levels 1-3 with a dictionary
|
147
|
+
* zstd -b1e3 -r /path/to/my/files -D /path/to/my/dictionary
|
148
|
+
*
|
149
|
+
* When should I retrain a dictionary?
|
150
|
+
* -----------------------------------
|
151
|
+
*
|
152
|
+
* You should retrain a dictionary when its effectiveness drops. Dictionary
|
153
|
+
* effectiveness drops as the data you are compressing changes. Generally, we do
|
154
|
+
* expect dictionaries to "decay" over time, as your data changes, but the rate
|
155
|
+
* at which they decay depends on your use case. Internally, we regularly
|
156
|
+
* retrain dictionaries, and if the new dictionary performs significantly
|
157
|
+
* better than the old dictionary, we will ship the new dictionary.
|
158
|
+
*
|
159
|
+
* I have a raw content dictionary, how do I turn it into a zstd dictionary?
|
160
|
+
* -------------------------------------------------------------------------
|
161
|
+
*
|
162
|
+
* If you have a raw content dictionary, e.g. by manually constructing it, or
|
163
|
+
* using a third-party dictionary builder, you can turn it into a zstd
|
164
|
+
* dictionary by using `ZDICT_finalizeDictionary()`. You'll also have to
|
165
|
+
* provide some samples of the data. It will add the zstd header to the
|
166
|
+
* raw content, which contains a dictionary ID and entropy tables, which
|
167
|
+
* will improve compression ratio, and allow zstd to write the dictionary ID
|
168
|
+
* into the frame, if you so choose.
|
169
|
+
*
|
170
|
+
* Do I have to use zstd's dictionary builder?
|
171
|
+
* -------------------------------------------
|
172
|
+
*
|
173
|
+
* No! You can construct dictionary content however you please, it is just
|
174
|
+
* bytes. It will always be valid as a raw content dictionary. If you want
|
175
|
+
* a zstd dictionary, which can improve compression ratio, use
|
176
|
+
* `ZDICT_finalizeDictionary()`.
|
177
|
+
*
|
178
|
+
* What is the attack surface of a zstd dictionary?
|
179
|
+
* ------------------------------------------------
|
180
|
+
*
|
181
|
+
* Zstd is heavily fuzz tested, including loading fuzzed dictionaries, so
|
182
|
+
* zstd should never crash, or access out-of-bounds memory no matter what
|
183
|
+
* the dictionary is. However, if an attacker can control the dictionary
|
184
|
+
* during decompression, they can cause zstd to generate arbitrary bytes,
|
185
|
+
* just like if they controlled the compressed data.
|
186
|
+
*
|
187
|
+
******************************************************************************/
|
188
|
+
|
39
189
|
|
40
190
|
/*! ZDICT_trainFromBuffer():
|
41
191
|
* Train a dictionary from an array of samples.
|
@@ -62,9 +212,16 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCap
|
|
62
212
|
const size_t* samplesSizes, unsigned nbSamples);
|
63
213
|
|
64
214
|
typedef struct {
|
65
|
-
int compressionLevel;
|
66
|
-
unsigned notificationLevel;
|
67
|
-
unsigned dictID;
|
215
|
+
int compressionLevel; /**< optimize for a specific zstd compression level; 0 means default */
|
216
|
+
unsigned notificationLevel; /**< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
|
217
|
+
unsigned dictID; /**< force dictID value; 0 means auto mode (32-bits random value)
|
218
|
+
* NOTE: The zstd format reserves some dictionary IDs for future use.
|
219
|
+
* You may use them in private settings, but be warned that they
|
220
|
+
* may be used by zstd in a public dictionary registry in the future.
|
221
|
+
* These dictionary IDs are:
|
222
|
+
* - low range : <= 32767
|
223
|
+
* - high range : >= (2^31)
|
224
|
+
*/
|
68
225
|
} ZDICT_params_t;
|
69
226
|
|
70
227
|
/*! ZDICT_finalizeDictionary():
|
@@ -91,7 +248,6 @@ typedef struct {
|
|
91
248
|
* is presumed that the most profitable content is at the end of the dictionary,
|
92
249
|
* since that is the cheapest to reference.
|
93
250
|
*
|
94
|
-
* `dictContentSize` must be >= ZDICT_CONTENTSIZE_MIN bytes.
|
95
251
|
* `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN).
|
96
252
|
*
|
97
253
|
* @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),
|
@@ -115,9 +271,21 @@ ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictS
|
|
115
271
|
ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
|
116
272
|
ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
|
117
273
|
|
274
|
+
#endif /* ZSTD_ZDICT_H */
|
118
275
|
|
276
|
+
#if defined(ZDICT_STATIC_LINKING_ONLY) && !defined(ZSTD_ZDICT_H_STATIC)
|
277
|
+
#define ZSTD_ZDICT_H_STATIC
|
119
278
|
|
120
|
-
|
279
|
+
/* This can be overridden externally to hide static symbols. */
|
280
|
+
#ifndef ZDICTLIB_STATIC_API
|
281
|
+
# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
282
|
+
# define ZDICTLIB_STATIC_API __declspec(dllexport) ZDICTLIB_VISIBLE
|
283
|
+
# elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
|
284
|
+
# define ZDICTLIB_STATIC_API __declspec(dllimport) ZDICTLIB_VISIBLE
|
285
|
+
# else
|
286
|
+
# define ZDICTLIB_STATIC_API ZDICTLIB_VISIBLE
|
287
|
+
# endif
|
288
|
+
#endif
|
121
289
|
|
122
290
|
/* ====================================================================================
|
123
291
|
* The definitions in this section are considered experimental.
|
@@ -126,8 +294,9 @@ ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
|
|
126
294
|
* Use them only in association with static linking.
|
127
295
|
* ==================================================================================== */
|
128
296
|
|
129
|
-
#define ZDICT_CONTENTSIZE_MIN 128
|
130
297
|
#define ZDICT_DICTSIZE_MIN 256
|
298
|
+
/* Deprecated: Remove in v1.6.0 */
|
299
|
+
#define ZDICT_CONTENTSIZE_MIN 128
|
131
300
|
|
132
301
|
/*! ZDICT_cover_params_t:
|
133
302
|
* k and d are the only required parameters.
|
@@ -172,7 +341,7 @@ typedef struct {
|
|
172
341
|
* In general, it's recommended to provide a few thousands samples, though this can vary a lot.
|
173
342
|
* It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
|
174
343
|
*/
|
175
|
-
|
344
|
+
ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_cover(
|
176
345
|
void *dictBuffer, size_t dictBufferCapacity,
|
177
346
|
const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
|
178
347
|
ZDICT_cover_params_t parameters);
|
@@ -194,7 +363,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
|
|
194
363
|
* See ZDICT_trainFromBuffer() for details on failure modes.
|
195
364
|
* Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread.
|
196
365
|
*/
|
197
|
-
|
366
|
+
ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_cover(
|
198
367
|
void* dictBuffer, size_t dictBufferCapacity,
|
199
368
|
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
|
200
369
|
ZDICT_cover_params_t* parameters);
|
@@ -215,7 +384,7 @@ ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
|
|
215
384
|
* In general, it's recommended to provide a few thousands samples, though this can vary a lot.
|
216
385
|
* It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
|
217
386
|
*/
|
218
|
-
|
387
|
+
ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
|
219
388
|
size_t dictBufferCapacity, const void *samplesBuffer,
|
220
389
|
const size_t *samplesSizes, unsigned nbSamples,
|
221
390
|
ZDICT_fastCover_params_t parameters);
|
@@ -238,7 +407,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
|
|
238
407
|
* See ZDICT_trainFromBuffer() for details on failure modes.
|
239
408
|
* Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread.
|
240
409
|
*/
|
241
|
-
|
410
|
+
ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
|
242
411
|
size_t dictBufferCapacity, const void* samplesBuffer,
|
243
412
|
const size_t* samplesSizes, unsigned nbSamples,
|
244
413
|
ZDICT_fastCover_params_t* parameters);
|
@@ -263,43 +432,43 @@ typedef struct {
|
|
263
432
|
* It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
|
264
433
|
* Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0.
|
265
434
|
*/
|
266
|
-
|
267
|
-
void
|
268
|
-
const void
|
435
|
+
ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_legacy(
|
436
|
+
void* dictBuffer, size_t dictBufferCapacity,
|
437
|
+
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
|
269
438
|
ZDICT_legacy_params_t parameters);
|
270
439
|
|
440
|
+
|
271
441
|
/* Deprecation warnings */
|
272
442
|
/* It is generally possible to disable deprecation warnings from compiler,
|
273
443
|
for example with -Wno-deprecated-declarations for gcc
|
274
444
|
or _CRT_SECURE_NO_WARNINGS in Visual.
|
275
445
|
Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */
|
276
446
|
#ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS
|
277
|
-
# define ZDICT_DEPRECATED(message)
|
447
|
+
# define ZDICT_DEPRECATED(message) /* disable deprecation warnings */
|
278
448
|
#else
|
279
449
|
# define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
280
450
|
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
281
|
-
# define ZDICT_DEPRECATED(message) [[deprecated(message)]]
|
282
|
-
# elif (ZDICT_GCC_VERSION >= 405)
|
283
|
-
# define ZDICT_DEPRECATED(message)
|
451
|
+
# define ZDICT_DEPRECATED(message) [[deprecated(message)]]
|
452
|
+
# elif defined(__clang__) || (ZDICT_GCC_VERSION >= 405)
|
453
|
+
# define ZDICT_DEPRECATED(message) __attribute__((deprecated(message)))
|
284
454
|
# elif (ZDICT_GCC_VERSION >= 301)
|
285
|
-
# define ZDICT_DEPRECATED(message)
|
455
|
+
# define ZDICT_DEPRECATED(message) __attribute__((deprecated))
|
286
456
|
# elif defined(_MSC_VER)
|
287
|
-
# define ZDICT_DEPRECATED(message)
|
457
|
+
# define ZDICT_DEPRECATED(message) __declspec(deprecated(message))
|
288
458
|
# else
|
289
459
|
# pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler")
|
290
|
-
# define ZDICT_DEPRECATED(message)
|
460
|
+
# define ZDICT_DEPRECATED(message)
|
291
461
|
# endif
|
292
462
|
#endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */
|
293
463
|
|
294
464
|
ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead")
|
465
|
+
ZDICTLIB_STATIC_API
|
295
466
|
size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
|
296
467
|
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
|
297
468
|
|
298
469
|
|
299
|
-
#endif /*
|
470
|
+
#endif /* ZSTD_ZDICT_H_STATIC */
|
300
471
|
|
301
472
|
#if defined (__cplusplus)
|
302
473
|
}
|
303
474
|
#endif
|
304
|
-
|
305
|
-
#endif /* DICTBUILDER_H_001 */
|