MySQL 8.3.0
Source Code Documentation
my_compress.h
Go to the documentation of this file.
1/* Copyright (c) 2019, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef MY_COMPRESS_INCLUDED
24#define MY_COMPRESS_INCLUDED
25
26/* List of valid values for compression_algorithm */
32};
33
34/**
35 Compress context information. relating to zlib compression.
36*/
37
39 /**
40 Compression level to use in zlib compression.
41 */
42 unsigned int compression_level;
44
45typedef struct ZSTD_CCtx_s ZSTD_CCtx;
46typedef struct ZSTD_DCtx_s ZSTD_DCtx;
47
48/**
49 Compress context information relating to zstd compression.
50*/
51
53 /**
54 Pointer to compressor context.
55 */
57 /**
58 Pointer to decompressor context.
59 */
61 /**
62 Compression level to use in zstd compression.
63 */
64 unsigned int compression_level;
66
67/**
68 Compression context information.
69 It encapsulate the context information based on compression method and
70 presents a generic struct.
71*/
72
73typedef struct mysql_compress_context {
74 enum enum_compression_algorithm algorithm; ///< Compression algorithm name.
75 union {
76 mysql_zlib_compress_context zlib_ctx; ///< Context information of zlib.
77 mysql_zstd_compress_context zstd_ctx; ///< Context information of zstd.
78 } u;
80
81/**
82 Get default compression level corresponding to a given compression method.
83
84 @param algorithm Compression Method. Possible values are zlib or zstd.
85
86 @return an unsigned int representing default compression level.
87 6 is the default compression level for zlib and 3 is the
88 default compression level for zstd.
89*/
90
92 enum enum_compression_algorithm algorithm);
93
94/**
95 Initialize a compress context object to be associated with a NET object.
96
97 @param cmp_ctx Pointer to compression context.
98 @param algorithm Compression algorithm.
99 @param compression_level Compression level corresponding to the compression
100 algorithm.
101*/
102
104 enum enum_compression_algorithm algorithm,
105 unsigned int compression_level);
106/**
107 Deinitialize the compression context allocated.
108
109 @param mysql_compress_ctx Pointer to Compression context.
110*/
111
113
114#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:350
struct mysql_zlib_compress_context mysql_zlib_compress_context
Compress context information.
struct ZSTD_CCtx_s ZSTD_CCtx
Definition: my_compress.h:45
struct ZSTD_DCtx_s ZSTD_DCtx
Definition: my_compress.h:46
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:58
enum_compression_algorithm
Definition: my_compress.h:27
@ MYSQL_ZSTD
Definition: my_compress.h:30
@ MYSQL_UNCOMPRESSED
Definition: my_compress.h:28
@ MYSQL_ZLIB
Definition: my_compress.h:29
@ MYSQL_INVALID
Definition: my_compress.h:31
void mysql_compress_context_deinit(mysql_compress_context *mysql_compress_ctx)
Deinitialize the compression context allocated.
Definition: my_compress.cc:78
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:73
union mysql_compress_context::@2 u
mysql_zstd_compress_context zstd_ctx
Context information of zstd.
Definition: my_compress.h:77
mysql_zlib_compress_context zlib_ctx
Context information of zlib.
Definition: my_compress.h:76
enum enum_compression_algorithm algorithm
Compression algorithm name.
Definition: my_compress.h:74
Compress context information.
Definition: my_compress.h:38
unsigned int compression_level
Compression level to use in zlib compression.
Definition: my_compress.h:42
Compress context information relating to zstd compression.
Definition: my_compress.h:52
unsigned int compression_level
Compression level to use in zstd compression.
Definition: my_compress.h:64
ZSTD_CCtx * cctx
Pointer to compressor context.
Definition: my_compress.h:56
ZSTD_DCtx * dctx
Pointer to decompressor context.
Definition: my_compress.h:60