comparison contrib/python-zstandard/c-ext/python-zstandard.h @ 42070:675775c33ab6

zstandard: vendor python-zstandard 0.11 The upstream source distribution from PyPI was extracted. Unwanted files were removed. The clang-format ignore list was updated to reflect the new source of files. The project contains a vendored copy of zstandard 1.3.8. The old version was 1.3.6. This should result in some minor performance wins. test-check-py3-compat.t was updated to reflect now-passing tests on Python 3.8. Some HTTP tests were updated to reflect new zstd compression output. # no-check-commit because 3rd party code has different style guidelines Differential Revision: https://phab.mercurial-scm.org/D6199
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 04 Apr 2019 17:34:43 -0700
parents 73fef626dae3
children 69de49c4e39c
comparison
equal deleted inserted replaced
42069:668eff08387f 42070:675775c33ab6
14 #define ZDICT_STATIC_LINKING_ONLY 14 #define ZDICT_STATIC_LINKING_ONLY
15 #include <zstd.h> 15 #include <zstd.h>
16 #include <zdict.h> 16 #include <zdict.h>
17 17
18 /* Remember to change the string in zstandard/__init__ as well */ 18 /* Remember to change the string in zstandard/__init__ as well */
19 #define PYTHON_ZSTANDARD_VERSION "0.10.1" 19 #define PYTHON_ZSTANDARD_VERSION "0.11.0"
20 20
21 typedef enum { 21 typedef enum {
22 compressorobj_flush_finish, 22 compressorobj_flush_finish,
23 compressorobj_flush_block, 23 compressorobj_flush_block,
24 } CompressorObj_Flush; 24 } CompressorObj_Flush;
29 This type holds all the low-level compression parameters that can be set. 29 This type holds all the low-level compression parameters that can be set.
30 */ 30 */
31 typedef struct { 31 typedef struct {
32 PyObject_HEAD 32 PyObject_HEAD
33 ZSTD_CCtx_params* params; 33 ZSTD_CCtx_params* params;
34 unsigned format;
35 int compressionLevel;
36 unsigned windowLog;
37 unsigned hashLog;
38 unsigned chainLog;
39 unsigned searchLog;
40 unsigned minMatch;
41 unsigned targetLength;
42 unsigned compressionStrategy;
43 unsigned contentSizeFlag;
44 unsigned checksumFlag;
45 unsigned dictIDFlag;
46 unsigned threads;
47 unsigned jobSize;
48 unsigned overlapSizeLog;
49 unsigned forceMaxWindow;
50 unsigned enableLongDistanceMatching;
51 unsigned ldmHashLog;
52 unsigned ldmMinMatch;
53 unsigned ldmBucketSizeLog;
54 unsigned ldmHashEveryLog;
55 } ZstdCompressionParametersObject; 34 } ZstdCompressionParametersObject;
56 35
57 extern PyTypeObject ZstdCompressionParametersType; 36 extern PyTypeObject ZstdCompressionParametersType;
58 37
59 /* 38 /*
127 typedef struct { 106 typedef struct {
128 PyObject_HEAD 107 PyObject_HEAD
129 108
130 ZstdCompressor* compressor; 109 ZstdCompressor* compressor;
131 PyObject* writer; 110 PyObject* writer;
132 unsigned long long sourceSize; 111 ZSTD_outBuffer output;
133 size_t outSize; 112 size_t outSize;
134 int entered; 113 int entered;
114 int closed;
115 int writeReturnRead;
135 unsigned long long bytesCompressed; 116 unsigned long long bytesCompressed;
136 } ZstdCompressionWriter; 117 } ZstdCompressionWriter;
137 118
138 extern PyTypeObject ZstdCompressionWriterType; 119 extern PyTypeObject ZstdCompressionWriterType;
139 120
233 ZstdDecompressor* decompressor; 214 ZstdDecompressor* decompressor;
234 /* Object to read() from (if reading from a stream). */ 215 /* Object to read() from (if reading from a stream). */
235 PyObject* reader; 216 PyObject* reader;
236 /* Size for read() operations on reader. */ 217 /* Size for read() operations on reader. */
237 size_t readSize; 218 size_t readSize;
219 /* Whether a read() can return data spanning multiple zstd frames. */
220 int readAcrossFrames;
238 /* Buffer to read from (if reading from a buffer). */ 221 /* Buffer to read from (if reading from a buffer). */
239 Py_buffer buffer; 222 Py_buffer buffer;
240 223
241 /* Whether the context manager is active. */ 224 /* Whether the context manager is active. */
242 int entered; 225 int entered;
265 248
266 ZstdDecompressor* decompressor; 249 ZstdDecompressor* decompressor;
267 PyObject* writer; 250 PyObject* writer;
268 size_t outSize; 251 size_t outSize;
269 int entered; 252 int entered;
253 int closed;
254 int writeReturnRead;
270 } ZstdDecompressionWriter; 255 } ZstdDecompressionWriter;
271 256
272 extern PyTypeObject ZstdDecompressionWriterType; 257 extern PyTypeObject ZstdDecompressionWriterType;
273 258
274 typedef struct { 259 typedef struct {
358 Py_ssize_t* firstElements; 343 Py_ssize_t* firstElements;
359 } ZstdBufferWithSegmentsCollection; 344 } ZstdBufferWithSegmentsCollection;
360 345
361 extern PyTypeObject ZstdBufferWithSegmentsCollectionType; 346 extern PyTypeObject ZstdBufferWithSegmentsCollectionType;
362 347
363 int set_parameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned value); 348 int set_parameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
364 int set_parameters(ZSTD_CCtx_params* params, ZstdCompressionParametersObject* obj); 349 int set_parameters(ZSTD_CCtx_params* params, ZstdCompressionParametersObject* obj);
350 int to_cparams(ZstdCompressionParametersObject* params, ZSTD_compressionParameters* cparams);
365 FrameParametersObject* get_frame_parameters(PyObject* self, PyObject* args, PyObject* kwargs); 351 FrameParametersObject* get_frame_parameters(PyObject* self, PyObject* args, PyObject* kwargs);
366 int ensure_ddict(ZstdCompressionDict* dict); 352 int ensure_ddict(ZstdCompressionDict* dict);
367 int ensure_dctx(ZstdDecompressor* decompressor, int loadDict); 353 int ensure_dctx(ZstdDecompressor* decompressor, int loadDict);
368 ZstdCompressionDict* train_dictionary(PyObject* self, PyObject* args, PyObject* kwargs); 354 ZstdCompressionDict* train_dictionary(PyObject* self, PyObject* args, PyObject* kwargs);
369 ZstdBufferWithSegments* BufferWithSegments_FromMemory(void* data, unsigned long long dataSize, BufferSegment* segments, Py_ssize_t segmentsSize); 355 ZstdBufferWithSegments* BufferWithSegments_FromMemory(void* data, unsigned long long dataSize, BufferSegment* segments, Py_ssize_t segmentsSize);