MySQL 9.1.0
Source Code Documentation
my_compress.h
Go to the documentation of this file.
1/* Copyright (c) 2019, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MY_COMPRESS_INCLUDED
25#define MY_COMPRESS_INCLUDED
26
27/* List of valid values for compression_algorithm */
33};
34
35/**
36 Compress context information. relating to zlib compression.
37*/
38
40 /**
41 Compression level to use in zlib compression.
42 */
43 unsigned int compression_level;
45
46typedef struct ZSTD_CCtx_s ZSTD_CCtx;
47typedef struct ZSTD_DCtx_s ZSTD_DCtx;
48
49/**
50 Compress context information relating to zstd compression.
51*/
52
54 /**
55 Pointer to compressor context.
56 */
58 /**
59 Pointer to decompressor context.
60 */
62 /**
63 Compression level to use in zstd compression.
64 */
65 unsigned int compression_level;
67
68/**
69 Compression context information.
70 It encapsulate the context information based on compression method and
71 presents a generic struct.
72*/
73
74typedef struct mysql_compress_context {
75 enum enum_compression_algorithm algorithm; ///< Compression algorithm name.
76 union {
77 mysql_zlib_compress_context zlib_ctx; ///< Context information of zlib.
78 mysql_zstd_compress_context zstd_ctx; ///< Context information of zstd.
79 } u;
81
82/**
83 Get default compression level corresponding to a given compression method.
84
85 @param algorithm Compression Method. Possible values are zlib or zstd.
86
87 @return an unsigned int representing default compression level.
88 6 is the default compression level for zlib and 3 is the
89 default compression level for zstd.
90*/
91
93 enum enum_compression_algorithm algorithm);
94
95/**
96 Initialize a compress context object to be associated with a NET object.
97
98 @param cmp_ctx Pointer to compression context.
99 @param algorithm Compression algorithm.
100 @param compression_level Compression level corresponding to the compression
101 algorithm.
102*/
103
105 enum enum_compression_algorithm algorithm,
106 unsigned int compression_level);
107/**
108 Deinitialize the compression context allocated.
109
110 @param mysql_compress_ctx Pointer to Compression context.
111*/
112
114
115#endif // MY_COMPRESS_INCLUDED
unsigned int mysql_default_compression_level(enum enum_compression_algorithm algorithm)
Get default compression level corresponding to a given compression method.
Definition: my_compress.cc:351
struct mysql_zlib_compress_context mysql_zlib_compress_context
Compress context information.
struct ZSTD_CCtx_s ZSTD_CCtx
Definition: my_compress.h:46
struct ZSTD_DCtx_s ZSTD_DCtx
Definition: my_compress.h:47
void mysql_compress_context_init(mysql_compress_context *cmp_ctx, enum enum_compression_algorithm algorithm, unsigned int compression_level)
Initialize a compress context object to be associated with a NET object.
Definition: my_compress.cc:59
enum_compression_algorithm
Definition: my_compress.h:28
@ MYSQL_ZSTD
Definition: my_compress.h:31
@ MYSQL_UNCOMPRESSED
Definition: my_compress.h:29
@ MYSQL_ZLIB
Definition: my_compress.h:30
@ MYSQL_INVALID
Definition: my_compress.h:32
void mysql_compress_context_deinit(mysql_compress_context *mysql_compress_ctx)
Deinitialize the compression context allocated.
Definition: my_compress.cc:79
struct mysql_compress_context mysql_compress_context
Compression context information.
struct mysql_zstd_compress_context mysql_zstd_compress_context
Compress context information relating to zstd compression.
Compression context information.
Definition: my_compress.h:74
union mysql_compress_context::@2 u
mysql_zstd_compress_context zstd_ctx
Context information of zstd.
Definition: my_compress.h:78
mysql_zlib_compress_context zlib_ctx
Context information of zlib.
Definition: my_compress.h:77
enum enum_compression_algorithm algorithm
Compression algorithm name.
Definition: my_compress.h:75
Compress context information.
Definition: my_compress.h:39
unsigned int compression_level
Compression level to use in zlib compression.
Definition: my_compress.h:43
Compress context information relating to zstd compression.
Definition: my_compress.h:53
unsigned int compression_level
Compression level to use in zstd compression.
Definition: my_compress.h:65
ZSTD_CCtx * cctx
Pointer to compressor context.
Definition: my_compress.h:57
ZSTD_DCtx * dctx
Pointer to decompressor context.
Definition: my_compress.h:61