extzstd 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.ja +5 -0
- data/README.md +5 -5
- data/contrib/zstd/CONTRIBUTING.md +42 -0
- data/contrib/zstd/LICENSE-examples +11 -0
- data/contrib/zstd/Makefile +315 -0
- data/contrib/zstd/NEWS +261 -0
- data/contrib/zstd/PATENTS +33 -0
- data/contrib/zstd/README.md +121 -41
- data/contrib/zstd/TESTING.md +44 -0
- data/contrib/zstd/appveyor.yml +178 -0
- data/contrib/zstd/circle.yml +75 -0
- data/contrib/zstd/lib/BUCK +186 -0
- data/contrib/zstd/lib/Makefile +163 -0
- data/contrib/zstd/lib/README.md +77 -0
- data/contrib/zstd/{common → lib/common}/bitstream.h +7 -4
- data/contrib/zstd/{common → lib/common}/entropy_common.c +19 -23
- data/contrib/zstd/{common → lib/common}/error_private.c +0 -0
- data/contrib/zstd/{common → lib/common}/error_private.h +0 -0
- data/contrib/zstd/{common → lib/common}/fse.h +94 -34
- data/contrib/zstd/{common → lib/common}/fse_decompress.c +18 -19
- data/contrib/zstd/{common → lib/common}/huf.h +52 -20
- data/contrib/zstd/{common → lib/common}/mem.h +17 -13
- data/contrib/zstd/lib/common/pool.c +194 -0
- data/contrib/zstd/lib/common/pool.h +56 -0
- data/contrib/zstd/lib/common/threading.c +80 -0
- data/contrib/zstd/lib/common/threading.h +104 -0
- data/contrib/zstd/{common → lib/common}/xxhash.c +3 -1
- data/contrib/zstd/{common → lib/common}/xxhash.h +11 -15
- data/contrib/zstd/{common → lib/common}/zstd_common.c +1 -11
- data/contrib/zstd/{common → lib/common}/zstd_errors.h +16 -2
- data/contrib/zstd/{common → lib/common}/zstd_internal.h +17 -1
- data/contrib/zstd/{compress → lib/compress}/fse_compress.c +138 -91
- data/contrib/zstd/{compress → lib/compress}/huf_compress.c +218 -67
- data/contrib/zstd/{compress → lib/compress}/zstd_compress.c +231 -108
- data/contrib/zstd/{compress → lib/compress}/zstd_opt.h +44 -25
- data/contrib/zstd/lib/compress/zstdmt_compress.c +739 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.h +78 -0
- data/contrib/zstd/{decompress → lib/decompress}/huf_decompress.c +28 -23
- data/contrib/zstd/{decompress → lib/decompress}/zstd_decompress.c +814 -176
- data/contrib/zstd/{common → lib/deprecated}/zbuff.h +60 -39
- data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +145 -0
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +74 -0
- data/contrib/zstd/lib/dictBuilder/cover.c +1029 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +0 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +0 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +68 -18
- data/contrib/zstd/lib/dictBuilder/zdict.h +201 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_legacy.h +122 -7
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +34 -3
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +45 -12
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +45 -12
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +56 -33
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +45 -18
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +7 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +43 -16
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +7 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.c +57 -23
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.h +8 -0
- data/contrib/zstd/lib/libzstd.pc.in +14 -0
- data/contrib/zstd/{zstd.h → lib/zstd.h} +206 -71
- data/ext/depend +2 -0
- data/ext/extconf.rb +4 -4
- data/ext/extzstd.c +1 -1
- data/ext/zstd_common.c +5 -5
- data/ext/zstd_compress.c +3 -3
- data/ext/zstd_decompress.c +2 -2
- data/ext/zstd_dictbuilder.c +2 -2
- data/ext/zstd_legacy_v01.c +1 -1
- data/ext/zstd_legacy_v02.c +1 -1
- data/ext/zstd_legacy_v03.c +1 -1
- data/ext/zstd_legacy_v04.c +1 -1
- data/ext/zstd_legacy_v05.c +1 -1
- data/ext/zstd_legacy_v06.c +1 -1
- data/ext/zstd_legacy_v07.c +1 -1
- data/gemstub.rb +9 -5
- data/lib/extzstd/version.rb +1 -1
- metadata +73 -51
- data/contrib/zstd/compress/zbuff_compress.c +0 -319
- data/contrib/zstd/decompress/zbuff_decompress.c +0 -252
- data/contrib/zstd/dictBuilder/zdict.h +0 -111
@@ -1,252 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*/
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
/* *************************************
|
13
|
-
* Dependencies
|
14
|
-
***************************************/
|
15
|
-
#include <stdlib.h>
|
16
|
-
#include "error_private.h"
|
17
|
-
#include "zstd_internal.h" /* MIN, ZSTD_blockHeaderSize, ZSTD_BLOCKSIZE_MAX */
|
18
|
-
#define ZBUFF_STATIC_LINKING_ONLY
|
19
|
-
#include "zbuff.h"
|
20
|
-
|
21
|
-
|
22
|
-
typedef enum { ZBUFFds_init, ZBUFFds_loadHeader,
|
23
|
-
ZBUFFds_read, ZBUFFds_load, ZBUFFds_flush } ZBUFF_dStage;
|
24
|
-
|
25
|
-
/* *** Resource management *** */
|
26
|
-
struct ZBUFF_DCtx_s {
|
27
|
-
ZSTD_DCtx* zd;
|
28
|
-
ZSTD_frameParams fParams;
|
29
|
-
ZBUFF_dStage stage;
|
30
|
-
char* inBuff;
|
31
|
-
size_t inBuffSize;
|
32
|
-
size_t inPos;
|
33
|
-
char* outBuff;
|
34
|
-
size_t outBuffSize;
|
35
|
-
size_t outStart;
|
36
|
-
size_t outEnd;
|
37
|
-
size_t blockSize;
|
38
|
-
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
|
39
|
-
size_t lhSize;
|
40
|
-
ZSTD_customMem customMem;
|
41
|
-
}; /* typedef'd to ZBUFF_DCtx within "zbuff.h" */
|
42
|
-
|
43
|
-
|
44
|
-
ZBUFF_DCtx* ZBUFF_createDCtx(void)
|
45
|
-
{
|
46
|
-
return ZBUFF_createDCtx_advanced(defaultCustomMem);
|
47
|
-
}
|
48
|
-
|
49
|
-
ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
|
50
|
-
{
|
51
|
-
ZBUFF_DCtx* zbd;
|
52
|
-
|
53
|
-
if (!customMem.customAlloc && !customMem.customFree)
|
54
|
-
customMem = defaultCustomMem;
|
55
|
-
|
56
|
-
if (!customMem.customAlloc || !customMem.customFree)
|
57
|
-
return NULL;
|
58
|
-
|
59
|
-
zbd = (ZBUFF_DCtx*)customMem.customAlloc(customMem.opaque, sizeof(ZBUFF_DCtx));
|
60
|
-
if (zbd==NULL) return NULL;
|
61
|
-
memset(zbd, 0, sizeof(ZBUFF_DCtx));
|
62
|
-
memcpy(&zbd->customMem, &customMem, sizeof(ZSTD_customMem));
|
63
|
-
zbd->zd = ZSTD_createDCtx_advanced(customMem);
|
64
|
-
if (zbd->zd == NULL) { ZBUFF_freeDCtx(zbd); return NULL; }
|
65
|
-
zbd->stage = ZBUFFds_init;
|
66
|
-
return zbd;
|
67
|
-
}
|
68
|
-
|
69
|
-
size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
|
70
|
-
{
|
71
|
-
if (zbd==NULL) return 0; /* support free on null */
|
72
|
-
ZSTD_freeDCtx(zbd->zd);
|
73
|
-
if (zbd->inBuff) zbd->customMem.customFree(zbd->customMem.opaque, zbd->inBuff);
|
74
|
-
if (zbd->outBuff) zbd->customMem.customFree(zbd->customMem.opaque, zbd->outBuff);
|
75
|
-
zbd->customMem.customFree(zbd->customMem.opaque, zbd);
|
76
|
-
return 0;
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
/* *** Initialization *** */
|
81
|
-
|
82
|
-
size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
|
83
|
-
{
|
84
|
-
zbd->stage = ZBUFFds_loadHeader;
|
85
|
-
zbd->lhSize = zbd->inPos = zbd->outStart = zbd->outEnd = 0;
|
86
|
-
return ZSTD_decompressBegin_usingDict(zbd->zd, dict, dictSize);
|
87
|
-
}
|
88
|
-
|
89
|
-
size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
|
90
|
-
{
|
91
|
-
return ZBUFF_decompressInitDictionary(zbd, NULL, 0);
|
92
|
-
}
|
93
|
-
|
94
|
-
|
95
|
-
/* internal util function */
|
96
|
-
MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
|
97
|
-
{
|
98
|
-
size_t const length = MIN(dstCapacity, srcSize);
|
99
|
-
memcpy(dst, src, length);
|
100
|
-
return length;
|
101
|
-
}
|
102
|
-
|
103
|
-
|
104
|
-
/* *** Decompression *** */
|
105
|
-
|
106
|
-
size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
|
107
|
-
void* dst, size_t* dstCapacityPtr,
|
108
|
-
const void* src, size_t* srcSizePtr)
|
109
|
-
{
|
110
|
-
const char* const istart = (const char*)src;
|
111
|
-
const char* const iend = istart + *srcSizePtr;
|
112
|
-
const char* ip = istart;
|
113
|
-
char* const ostart = (char*)dst;
|
114
|
-
char* const oend = ostart + *dstCapacityPtr;
|
115
|
-
char* op = ostart;
|
116
|
-
U32 someMoreWork = 1;
|
117
|
-
|
118
|
-
while (someMoreWork) {
|
119
|
-
switch(zbd->stage)
|
120
|
-
{
|
121
|
-
case ZBUFFds_init :
|
122
|
-
return ERROR(init_missing);
|
123
|
-
|
124
|
-
case ZBUFFds_loadHeader :
|
125
|
-
{ size_t const hSize = ZSTD_getFrameParams(&(zbd->fParams), zbd->headerBuffer, zbd->lhSize);
|
126
|
-
if (ZSTD_isError(hSize)) return hSize;
|
127
|
-
if (hSize != 0) { /* need more input */
|
128
|
-
size_t const toLoad = hSize - zbd->lhSize; /* if hSize!=0, hSize > zbd->lhSize */
|
129
|
-
if (toLoad > (size_t)(iend-ip)) { /* not enough input to load full header */
|
130
|
-
memcpy(zbd->headerBuffer + zbd->lhSize, ip, iend-ip);
|
131
|
-
zbd->lhSize += iend-ip;
|
132
|
-
*dstCapacityPtr = 0;
|
133
|
-
return (hSize - zbd->lhSize) + ZSTD_blockHeaderSize; /* remaining header bytes + next block header */
|
134
|
-
}
|
135
|
-
memcpy(zbd->headerBuffer + zbd->lhSize, ip, toLoad); zbd->lhSize = hSize; ip += toLoad;
|
136
|
-
break;
|
137
|
-
} }
|
138
|
-
|
139
|
-
/* Consume header */
|
140
|
-
{ size_t const h1Size = ZSTD_nextSrcSizeToDecompress(zbd->zd); /* == ZSTD_frameHeaderSize_min */
|
141
|
-
size_t const h1Result = ZSTD_decompressContinue(zbd->zd, NULL, 0, zbd->headerBuffer, h1Size);
|
142
|
-
if (ZSTD_isError(h1Result)) return h1Result; /* should not happen : already checked */
|
143
|
-
if (h1Size < zbd->lhSize) { /* long header */
|
144
|
-
size_t const h2Size = ZSTD_nextSrcSizeToDecompress(zbd->zd);
|
145
|
-
size_t const h2Result = ZSTD_decompressContinue(zbd->zd, NULL, 0, zbd->headerBuffer+h1Size, h2Size);
|
146
|
-
if (ZSTD_isError(h2Result)) return h2Result;
|
147
|
-
} }
|
148
|
-
|
149
|
-
zbd->fParams.windowSize = MAX(zbd->fParams.windowSize, 1U << ZSTD_WINDOWLOG_ABSOLUTEMIN);
|
150
|
-
|
151
|
-
/* Frame header instruct buffer sizes */
|
152
|
-
{ size_t const blockSize = MIN(zbd->fParams.windowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX);
|
153
|
-
size_t const neededOutSize = zbd->fParams.windowSize + blockSize;
|
154
|
-
zbd->blockSize = blockSize;
|
155
|
-
if (zbd->inBuffSize < blockSize) {
|
156
|
-
zbd->customMem.customFree(zbd->customMem.opaque, zbd->inBuff);
|
157
|
-
zbd->inBuffSize = blockSize;
|
158
|
-
zbd->inBuff = (char*)zbd->customMem.customAlloc(zbd->customMem.opaque, blockSize);
|
159
|
-
if (zbd->inBuff == NULL) return ERROR(memory_allocation);
|
160
|
-
}
|
161
|
-
if (zbd->outBuffSize < neededOutSize) {
|
162
|
-
zbd->customMem.customFree(zbd->customMem.opaque, zbd->outBuff);
|
163
|
-
zbd->outBuffSize = neededOutSize;
|
164
|
-
zbd->outBuff = (char*)zbd->customMem.customAlloc(zbd->customMem.opaque, neededOutSize);
|
165
|
-
if (zbd->outBuff == NULL) return ERROR(memory_allocation);
|
166
|
-
} }
|
167
|
-
zbd->stage = ZBUFFds_read;
|
168
|
-
/* pass-through */
|
169
|
-
|
170
|
-
case ZBUFFds_read:
|
171
|
-
{ size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zbd->zd);
|
172
|
-
if (neededInSize==0) { /* end of frame */
|
173
|
-
zbd->stage = ZBUFFds_init;
|
174
|
-
someMoreWork = 0;
|
175
|
-
break;
|
176
|
-
}
|
177
|
-
if ((size_t)(iend-ip) >= neededInSize) { /* decode directly from src */
|
178
|
-
const int isSkipFrame = ZSTD_isSkipFrame(zbd->zd);
|
179
|
-
size_t const decodedSize = ZSTD_decompressContinue(zbd->zd,
|
180
|
-
zbd->outBuff + zbd->outStart, (isSkipFrame ? 0 : zbd->outBuffSize - zbd->outStart),
|
181
|
-
ip, neededInSize);
|
182
|
-
if (ZSTD_isError(decodedSize)) return decodedSize;
|
183
|
-
ip += neededInSize;
|
184
|
-
if (!decodedSize && !isSkipFrame) break; /* this was just a header */
|
185
|
-
zbd->outEnd = zbd->outStart + decodedSize;
|
186
|
-
zbd->stage = ZBUFFds_flush;
|
187
|
-
break;
|
188
|
-
}
|
189
|
-
if (ip==iend) { someMoreWork = 0; break; } /* no more input */
|
190
|
-
zbd->stage = ZBUFFds_load;
|
191
|
-
/* pass-through */
|
192
|
-
}
|
193
|
-
|
194
|
-
case ZBUFFds_load:
|
195
|
-
{ size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zbd->zd);
|
196
|
-
size_t const toLoad = neededInSize - zbd->inPos; /* should always be <= remaining space within inBuff */
|
197
|
-
size_t loadedSize;
|
198
|
-
if (toLoad > zbd->inBuffSize - zbd->inPos) return ERROR(corruption_detected); /* should never happen */
|
199
|
-
loadedSize = ZBUFF_limitCopy(zbd->inBuff + zbd->inPos, toLoad, ip, iend-ip);
|
200
|
-
ip += loadedSize;
|
201
|
-
zbd->inPos += loadedSize;
|
202
|
-
if (loadedSize < toLoad) { someMoreWork = 0; break; } /* not enough input, wait for more */
|
203
|
-
|
204
|
-
/* decode loaded input */
|
205
|
-
{ const int isSkipFrame = ZSTD_isSkipFrame(zbd->zd);
|
206
|
-
size_t const decodedSize = ZSTD_decompressContinue(zbd->zd,
|
207
|
-
zbd->outBuff + zbd->outStart, zbd->outBuffSize - zbd->outStart,
|
208
|
-
zbd->inBuff, neededInSize);
|
209
|
-
if (ZSTD_isError(decodedSize)) return decodedSize;
|
210
|
-
zbd->inPos = 0; /* input is consumed */
|
211
|
-
if (!decodedSize && !isSkipFrame) { zbd->stage = ZBUFFds_read; break; } /* this was just a header */
|
212
|
-
zbd->outEnd = zbd->outStart + decodedSize;
|
213
|
-
zbd->stage = ZBUFFds_flush;
|
214
|
-
/* pass-through */
|
215
|
-
} }
|
216
|
-
|
217
|
-
case ZBUFFds_flush:
|
218
|
-
{ size_t const toFlushSize = zbd->outEnd - zbd->outStart;
|
219
|
-
size_t const flushedSize = ZBUFF_limitCopy(op, oend-op, zbd->outBuff + zbd->outStart, toFlushSize);
|
220
|
-
op += flushedSize;
|
221
|
-
zbd->outStart += flushedSize;
|
222
|
-
if (flushedSize == toFlushSize) { /* flush completed */
|
223
|
-
zbd->stage = ZBUFFds_read;
|
224
|
-
if (zbd->outStart + zbd->blockSize > zbd->outBuffSize)
|
225
|
-
zbd->outStart = zbd->outEnd = 0;
|
226
|
-
break;
|
227
|
-
}
|
228
|
-
/* cannot flush everything */
|
229
|
-
someMoreWork = 0;
|
230
|
-
break;
|
231
|
-
}
|
232
|
-
default: return ERROR(GENERIC); /* impossible */
|
233
|
-
} }
|
234
|
-
|
235
|
-
/* result */
|
236
|
-
*srcSizePtr = ip-istart;
|
237
|
-
*dstCapacityPtr = op-ostart;
|
238
|
-
{ size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zbd->zd);
|
239
|
-
if (!nextSrcSizeHint) return (zbd->outEnd != zbd->outStart); /* return 0 only if fully flushed too */
|
240
|
-
nextSrcSizeHint += ZSTD_blockHeaderSize * (ZSTD_nextInputType(zbd->zd) == ZSTDnit_block);
|
241
|
-
if (zbd->inPos > nextSrcSizeHint) return ERROR(GENERIC); /* should never happen */
|
242
|
-
nextSrcSizeHint -= zbd->inPos; /* already loaded*/
|
243
|
-
return nextSrcSizeHint;
|
244
|
-
}
|
245
|
-
}
|
246
|
-
|
247
|
-
|
248
|
-
/* *************************************
|
249
|
-
* Tool functions
|
250
|
-
***************************************/
|
251
|
-
size_t ZBUFF_recommendedDInSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX + ZSTD_blockHeaderSize /* block header size*/ ; }
|
252
|
-
size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX; }
|
@@ -1,111 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*/
|
9
|
-
|
10
|
-
#ifndef DICTBUILDER_H_001
|
11
|
-
#define DICTBUILDER_H_001
|
12
|
-
|
13
|
-
#if defined (__cplusplus)
|
14
|
-
extern "C" {
|
15
|
-
#endif
|
16
|
-
|
17
|
-
|
18
|
-
/*====== Dependencies ======*/
|
19
|
-
#include <stddef.h> /* size_t */
|
20
|
-
|
21
|
-
|
22
|
-
/*====== Export for Windows ======*/
|
23
|
-
/*!
|
24
|
-
* ZSTD_DLL_EXPORT :
|
25
|
-
* Enable exporting of functions when building a Windows DLL
|
26
|
-
*/
|
27
|
-
#if defined(_WIN32) && defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
28
|
-
# define ZDICTLIB_API __declspec(dllexport)
|
29
|
-
#else
|
30
|
-
# define ZDICTLIB_API
|
31
|
-
#endif
|
32
|
-
|
33
|
-
|
34
|
-
/*! ZDICT_trainFromBuffer() :
|
35
|
-
Train a dictionary from an array of samples.
|
36
|
-
Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
|
37
|
-
supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
|
38
|
-
The resulting dictionary will be saved into `dictBuffer`.
|
39
|
-
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
|
40
|
-
or an error code, which can be tested with ZDICT_isError().
|
41
|
-
Tips : In general, a reasonable dictionary has a size of ~ 100 KB.
|
42
|
-
It's obviously possible to target smaller or larger ones, just by specifying different `dictBufferCapacity`.
|
43
|
-
In general, it's recommended to provide a few thousands samples, but this can vary a lot.
|
44
|
-
It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
|
45
|
-
*/
|
46
|
-
ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity,
|
47
|
-
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
|
48
|
-
|
49
|
-
|
50
|
-
/*====== Helper functions ======*/
|
51
|
-
ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */
|
52
|
-
ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
|
53
|
-
ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#ifdef ZDICT_STATIC_LINKING_ONLY
|
58
|
-
|
59
|
-
/* ====================================================================================
|
60
|
-
* The definitions in this section are considered experimental.
|
61
|
-
* They should never be used with a dynamic library, as they may change in the future.
|
62
|
-
* They are provided for advanced usages.
|
63
|
-
* Use them only in association with static linking.
|
64
|
-
* ==================================================================================== */
|
65
|
-
|
66
|
-
typedef struct {
|
67
|
-
unsigned selectivityLevel; /* 0 means default; larger => select more => larger dictionary */
|
68
|
-
int compressionLevel; /* 0 means default; target a specific zstd compression level */
|
69
|
-
unsigned notificationLevel; /* Write to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
|
70
|
-
unsigned dictID; /* 0 means auto mode (32-bits random value); other : force dictID value */
|
71
|
-
unsigned reserved[2]; /* reserved space for future parameters */
|
72
|
-
} ZDICT_params_t;
|
73
|
-
|
74
|
-
|
75
|
-
/*! ZDICT_trainFromBuffer_advanced() :
|
76
|
-
Same as ZDICT_trainFromBuffer() with control over more parameters.
|
77
|
-
`parameters` is optional and can be provided with values set to 0 to mean "default".
|
78
|
-
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferSize`),
|
79
|
-
or an error code, which can be tested by ZDICT_isError().
|
80
|
-
note : ZDICT_trainFromBuffer_advanced() will send notifications into stderr if instructed to, using notificationLevel>0.
|
81
|
-
*/
|
82
|
-
size_t ZDICT_trainFromBuffer_advanced(void* dictBuffer, size_t dictBufferCapacity,
|
83
|
-
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
|
84
|
-
ZDICT_params_t parameters);
|
85
|
-
|
86
|
-
|
87
|
-
/*! ZDICT_addEntropyTablesFromBuffer() :
|
88
|
-
|
89
|
-
Given a content-only dictionary (built using any 3rd party algorithm),
|
90
|
-
add entropy tables computed from an array of samples.
|
91
|
-
Samples must be stored concatenated in a flat buffer `samplesBuffer`,
|
92
|
-
supplied with an array of sizes `samplesSizes`, providing the size of each sample in order.
|
93
|
-
|
94
|
-
The input dictionary content must be stored *at the end* of `dictBuffer`.
|
95
|
-
Its size is `dictContentSize`.
|
96
|
-
The resulting dictionary with added entropy tables will be *written back to `dictBuffer`*,
|
97
|
-
starting from its beginning.
|
98
|
-
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`).
|
99
|
-
*/
|
100
|
-
size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
|
101
|
-
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
#endif /* ZDICT_STATIC_LINKING_ONLY */
|
106
|
-
|
107
|
-
#if defined (__cplusplus)
|
108
|
-
}
|
109
|
-
#endif
|
110
|
-
|
111
|
-
#endif /* DICTBUILDER_H_001 */
|