MySQL  8.0.21
Source Code Documentation
my_compress.h
Go to the documentation of this file.
1 /* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
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 
45 typedef struct ZSTD_CCtx_s ZSTD_CCtx;
46 typedef 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 
73 typedef 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 
112 void mysql_compress_context_deinit(mysql_compress_context *mysql_compress_ctx);
113 
114 #endif // MY_COMPRESS_INCLUDED
Definition: my_compress.h:28
ZSTD_CCtx * cctx
Pointer to compressor context.
Definition: my_compress.h:56
mysql_zlib_compress_context zlib_ctx
Context information of zlib.
Definition: my_compress.h:76
void mysql_compress_context_deinit(mysql_compress_context *mysql_compress_ctx)
Deinitialize the compression context allocated.
Definition: my_compress.cc:78
struct mysql_zstd_compress_context mysql_zstd_compress_context
Compress context information relating to zstd compression.
enum_compression_algorithm
Definition: my_compress.h:27
struct ZSTD_CCtx_s ZSTD_CCtx
Definition: my_compress.h:45
Compress context information.
Definition: my_compress.h:38
unsigned int compression_level
Compression level to use in zstd compression.
Definition: my_compress.h:64
Compression context information.
Definition: my_compress.h:73
struct ZSTD_DCtx_s ZSTD_DCtx
Definition: my_compress.h:46
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.
ZSTD_DCtx * dctx
Pointer to decompressor context.
Definition: my_compress.h:60
Definition: my_compress.h:29
Compress context information relating to zstd compression.
Definition: my_compress.h:52
unsigned int compression_level
Compression level to use in zlib compression.
Definition: my_compress.h:42
Definition: my_compress.h:31
mysql_zstd_compress_context zstd_ctx
Context information of zstd.
Definition: my_compress.h:77
Definition: my_compress.h:30
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
struct mysql_compress_context mysql_compress_context
Compression context information.