MySQL 8.4.0
Source Code Documentation
gr_decompression.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 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 GROUP_REPLICATION_DECOMPRESSION_INCLUDE
25#define GROUP_REPLICATION_DECOMPRESSION_INCLUDE
26
32
33/*
34 Implements Decompressor.
35*/
37 public:
43 using String_t = std::basic_string<Char_t>;
44
45 /**
46 Decompression Error
47 */
49 /* No Error */
51 /* Unkown compression type. */
53 /* Compression library initialization error. */
55 /* Exceed max output buffer size. */
57 /* Memory allocation failure. */
59 /* No remaining bytes, less output than requested */
61 /* Compression library reported an error. */
63 /* No more input bytes to consume, output unchanged. */
65 };
66
67 /*
68 Constructor
69
70 @param[in] compression_type the GR_compress::enum_compression_type
71 compression type
72 */
75
76 /*
77 Destructor
78 */
80
81 /**
82 This shall decompress the buffer provided and put the
83 decompressed payload into the output buffer i.e. m_managed_buffer.
84
85 @param compressed_data the pointer to the input buffer holding the
86 compressed data which needs to decompress.
87 @param compressed_data_length the size of the input data to decompress.
88 @param output_size the exact size of output decompressed data.
89
90 Note: The caller needs to provide exact expected decompressed data in
91 in param 'output_size'.
92 The ZSTD library api in libbinlogevents does have other api's which
93 can be used to get decompressed data in several loops. But in this
94 implementation user has to provide exact size he expects after
95 decompressing data.
96
97 @return GR_compress::enum_decompression_error error type.
98 */
100 const unsigned char *compressed_data, size_t compressed_data_length,
101 size_t output_size);
102
103 /*
104 Return the uncompressed data and size.
105
106 @return a pair containing the uncompressed data and size.
107 In case of error the pair containing nullptr and 0 size is returned.
108 */
109 std::pair<unsigned char *, std::size_t> get_buffer();
110
111 private:
112 /** ZSTD decompressor class object. */
114
115 /** The compression type. */
118
119 /** The compression library name. */
120 std::string m_compressor_name{"Zstandard"};
121
122 /** The compression status. */
124
125 /** The buffer holding decompressed data. */
127};
128#endif /* GROUP_REPLICATION_DECOMPRESSION_INCLUDE */
enum_compression_type
Compression Type.
Definition: gr_compression.h:46
Definition: gr_decompression.h:36
Managed_buffer_t m_managed_buffer
The buffer holding decompressed data.
Definition: gr_decompression.h:126
GR_decompress::enum_decompression_error decompress(const unsigned char *compressed_data, size_t compressed_data_length, size_t output_size)
This shall decompress the buffer provided and put the decompressed payload into the output buffer i....
Definition: gr_decompression.cc:78
std::string m_compressor_name
The compression library name.
Definition: gr_decompression.h:120
GR_compress::enum_compression_type m_compression_type
The compression type.
Definition: gr_decompression.h:116
Decompressor_t::Char_t Char_t
Definition: gr_decompression.h:42
~GR_decompress()
Definition: gr_decompression.cc:71
std::basic_string< Char_t > String_t
Definition: gr_decompression.h:43
std::pair< unsigned char *, std::size_t > get_buffer()
Definition: gr_decompression.cc:176
Decompress_status_t m_status
The compression status.
Definition: gr_decompression.h:123
GR_decompress(GR_compress::enum_compression_type compression_type=GR_compress::enum_compression_type::ZSTD_COMPRESSION)
Definition: gr_decompression.cc:32
Decompressor_t * m_decompressor
ZSTD decompressor class object.
Definition: gr_decompression.h:113
enum_decompression_error
Decompression Error.
Definition: gr_decompression.h:48
Abstract base class for decompressors.
Definition: decompressor.h:57
unsigned char Char_t
Definition: decompressor.h:59
mysql::binlog::event::compression::buffer::Managed_buffer< Char_t > Managed_buffer_t
Definition: decompressor.h:63
Owned, growable, contiguous memory buffer.
Definition: managed_buffer.h:109
Container class that provides a contiguous memory buffer to the caller, which the caller can request ...
Decompress_status
Definition: decompress_status.h:32