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