Skip to content

Commit cf3d805

Browse files
author
Sven Sandberg
committed
BUG#36381815 step 5: Move binlog/event/compression/buffer to new library containers
Part of: Bug#36381815: Factor out generic functionality from the mysql_binlog_event library The contents of binlog/event/compression/buffer is generic and does not depend on binlog events. Move it to the subdirectory "buffers" of the new library "containers". This commit was produced using: ./libs/scripts/create library containers ./libs/scripts/move --force directory \ binlog/event/compression/buffer containers/buffers sed --in-place 's/mysql_gtid/mysql_containers\n mysql_gtid/' \ plugin/group_replication/CMakeLists.txt \ libs/mysql/binlog/event/CMakeLists.txt sed --in-place 's/ buffer::/ /' \ libs/mysql/containers/buffers/managed_buffer.h \ unittest/gunit/binlogevents/managed_buffer-t.cc \ unittest/gunit/binlogevents/managed_buffer_sequence-t.cc \ libs/mysql/containers/buffers/buffer_sequence_view.h \ libs/mysql/containers/buffers/managed_buffer_sequence.h \ libs/mysql/containers/buffers/rw_buffer_sequence.h \ libs/mysql/containers/buffers/buffer_view.h \ And then auto-reformatting. Change-Id: Id7416b7466b8f9bafc70c843f4b1835f4db04984
1 parent 4e6f1a3 commit cf3d805

33 files changed

+226
-172
lines changed

client/mysqlbinlog.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class Database_rewrite {
176176
using Compress_status_t =
177177
mysql::binlog::event::compression::Compress_status;
178178
using Managed_buffer_sequence_t =
179-
mysql::binlog::event::compression::buffer::Managed_buffer_sequence<>;
179+
mysql::containers::buffers::Managed_buffer_sequence<>;
180180
using Char_t = Managed_buffer_sequence_t::Char_t;
181181
Managed_buffer_sequence_t managed_buffer_sequence;
182182
auto compressor =

libs/mysql/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2323

2424
ADD_SUBDIRECTORY(allocators)
25+
ADD_SUBDIRECTORY(containers)
2526
ADD_SUBDIRECTORY(utils)
2627
ADD_SUBDIRECTORY(serialization)
2728
ADD_SUBDIRECTORY(gtid)

libs/mysql/binlog/event/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
SET(LINK_LIBRARIES
2525
ext::zstd
2626
ext::zlib
27+
mysql_containers
2728
mysql_gtid
2829
mysql_serialization
2930
)
@@ -78,9 +79,6 @@ SET(TARGET_SRCS
7879
compression/payload_event_buffer_istream.cpp
7980
compression/zstd_comp.cpp
8081
compression/zstd_dec.cpp
81-
compression/buffer/grow_calculator.cpp
82-
compression/buffer/grow_constraint.cpp
83-
compression/buffer/grow_status.cpp
8482
)
8583

8684
ADD_WSHADOW_WARNING()

libs/mysql/binlog/event/compression/compressor.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626

2727
#include <cstddef>
2828
#include <tuple>
29-
#include "mysql/binlog/event/compression/base.h" // type
30-
#include "mysql/binlog/event/compression/buffer/grow_constraint.h" // Grow_constraint
31-
#include "mysql/binlog/event/compression/buffer/managed_buffer_sequence.h" // Managed_buffer_sequence
32-
#include "mysql/utils/nodiscard.h" // NODISCARD
29+
#include "mysql/binlog/event/compression/base.h" // type
30+
#include "mysql/containers/buffers/grow_constraint.h" // Grow_constraint
31+
#include "mysql/containers/buffers/managed_buffer_sequence.h" // Managed_buffer_sequence
32+
#include "mysql/utils/nodiscard.h" // NODISCARD
3333

3434
#include <limits> // std::numeric_limits
3535

3636
namespace mysql::binlog::event::compression {
3737

38-
using Compress_status = mysql::binlog::event::compression::buffer::Grow_status;
38+
using Compress_status = mysql::containers::buffers::Grow_status;
3939

4040
/// Abstract base class for compressors.
4141
///
@@ -75,16 +75,15 @@ using Compress_status = mysql::binlog::event::compression::buffer::Grow_status;
7575
/// above procedure as many times as needed.
7676
///
7777
/// This class requires that the user provides a @c
78-
/// mysql::binlog::event::compression::buffer::Managed_buffer_sequence to
78+
/// mysql::containers::buffers::Managed_buffer_sequence to
7979
/// store output.
8080
class Compressor {
8181
public:
8282
using Managed_buffer_sequence_t =
83-
mysql::binlog::event::compression::buffer::Managed_buffer_sequence<>;
83+
mysql::containers::buffers::Managed_buffer_sequence<>;
8484
using Char_t = Managed_buffer_sequence_t::Char_t;
8585
using Size_t = Managed_buffer_sequence_t::Size_t;
86-
using Grow_constraint_t =
87-
mysql::binlog::event::compression::buffer::Grow_constraint;
86+
using Grow_constraint_t = mysql::containers::buffers::Grow_constraint;
8887
static constexpr Size_t pledged_input_size_unset =
8988
std::numeric_limits<Size_t>::max();
9089

libs/mysql/binlog/event/compression/decompressor.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
#ifndef MYSQL_BINLOG_EVENT_COMPRESSION_DECOMPRESSOR_H
2525
#define MYSQL_BINLOG_EVENT_COMPRESSION_DECOMPRESSOR_H
2626

27-
#include "mysql/binlog/event/compression/base.h" // type
28-
#include "mysql/binlog/event/compression/buffer/grow_constraint.h" // Grow_constraint
29-
#include "mysql/binlog/event/compression/buffer/managed_buffer.h" // Managed_buffer
27+
#include "mysql/binlog/event/compression/base.h" // type
3028
#include "mysql/binlog/event/compression/decompress_status.h" // Decompress_status
31-
#include "mysql/utils/nodiscard.h" // NODISCARD
29+
#include "mysql/containers/buffers/grow_constraint.h" // Grow_constraint
30+
#include "mysql/containers/buffers/managed_buffer.h" // Managed_buffer
31+
#include "mysql/utils/nodiscard.h" // NODISCARD
3232

3333
namespace mysql::binlog::event::compression {
3434

@@ -57,15 +57,12 @@ namespace mysql::binlog::event::compression {
5757
class Decompressor {
5858
public:
5959
using Char_t = unsigned char;
60-
using Size_t =
61-
mysql::binlog::event::compression::buffer::Buffer_view<Char_t>::Size_t;
62-
using Managed_buffer_t =
63-
mysql::binlog::event::compression::buffer::Managed_buffer<Char_t>;
64-
using Grow_constraint_t =
65-
mysql::binlog::event::compression::buffer::Grow_constraint;
60+
using Size_t = mysql::containers::buffers::Buffer_view<Char_t>::Size_t;
61+
using Managed_buffer_t = mysql::containers::buffers::Managed_buffer<Char_t>;
62+
using Grow_constraint_t = mysql::containers::buffers::Grow_constraint;
6663

6764
private:
68-
using Grow_status_t = mysql::binlog::event::compression::buffer::Grow_status;
65+
using Grow_status_t = mysql::containers::buffers::Grow_status;
6966

7067
public:
7168
Decompressor() = default;

libs/mysql/binlog/event/compression/payload_event_buffer_istream.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
#include <memory>
2828
#include <string>
2929

30-
#include "mysql/binlog/event/compression/buffer/managed_buffer.h" // mysql::binlog::event::compression::buffer::Managed_buffer
3130
#include "mysql/binlog/event/compression/decompressor.h" // mysqlns::compression::Decompressor
3231
#include "mysql/binlog/event/compression/factory.h" // mysqlns::compression::Factory
3332
#include "mysql/binlog/event/control_events.h" // Transaction_payload_event
3433
#include "mysql/binlog/event/event_reader.h" // Event_reader
35-
#include "mysql/utils/nodiscard.h" // NODISCARD
34+
#include "mysql/containers/buffers/managed_buffer.h" // mysql::containers::buffers::Managed_buffer
35+
#include "mysql/utils/nodiscard.h" // NODISCARD
3636

3737
/// @addtogroup GroupLibsMysqlBinlogEvent
3838
/// @{
@@ -59,12 +59,9 @@ namespace mysql::binlog::event::compression {
5959
class Payload_event_buffer_istream {
6060
public:
6161
using Char_t = unsigned char;
62-
using Size_t =
63-
mysql::binlog::event::compression::buffer::Buffer_view<Char_t>::Size_t;
64-
using Grow_calculator_t =
65-
mysql::binlog::event::compression::buffer::Grow_calculator;
66-
using Managed_buffer_t =
67-
mysql::binlog::event::compression::buffer::Managed_buffer<Char_t>;
62+
using Size_t = mysql::containers::buffers::Buffer_view<Char_t>::Size_t;
63+
using Grow_calculator_t = mysql::containers::buffers::Grow_calculator;
64+
using Managed_buffer_t = mysql::containers::buffers::Managed_buffer<Char_t>;
6865
using Decompressor_t = Decompressor;
6966
using Status_t = Decompress_status;
7067
using Factory_t = Factory;

libs/mysql/binlog/event/compression/zstd_comp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#include <zstd.h>
2929

3030
#include "mysql/allocators/memory_resource.h" // Memory_resource
31-
#include "mysql/binlog/event/compression/buffer/buffer_sequence_view.h"
3231
#include "mysql/binlog/event/compression/compressor.h"
32+
#include "mysql/containers/buffers/buffer_sequence_view.h"
3333
#include "mysql/utils/nodiscard.h"
3434

3535
struct ZSTD_outBuffer_s;

libs/mysql/binlog/event/control_events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#include "mysql/binlog/event/binlog_event.h"
4444
#include "mysql/binlog/event/compression/base.h" // mysql::binlog::event::compression::type
45-
#include "mysql/binlog/event/compression/buffer/buffer_sequence_view.h" // Buffer_sequence_view
45+
#include "mysql/containers/buffers/buffer_sequence_view.h" // Buffer_sequence_view
4646
#include "mysql/gtid/gtid_constants.h"
4747
#include "mysql/gtid/tsid.h"
4848
#include "mysql/gtid/uuid.h"
@@ -735,7 +735,7 @@ struct gtid_info {
735735
class Transaction_payload_event : public Binary_log_event {
736736
public:
737737
using Buffer_sequence_view_t =
738-
mysql::binlog::event::compression::buffer::Buffer_sequence_view<>;
738+
mysql::containers::buffers::Buffer_sequence_view<>;
739739

740740
private:
741741
Transaction_payload_event &operator=(const Transaction_payload_event &) =

libs/mysql/containers/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 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 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+
SET(TARGET_HEADERS
24+
)
25+
26+
SET(TARGET_SRCS
27+
buffers/grow_calculator.cpp
28+
buffers/grow_constraint.cpp
29+
buffers/grow_status.cpp
30+
)
31+
32+
LIBS_MYSQL_CREATE_LIBRARY(mysql_containers
33+
TARGET_SRCS ${TARGET_SRCS}
34+
TARGET_HEADERS ${TARGET_HEADERS}
35+
)

libs/mysql/binlog/event/compression/buffer/buffer_sequence_view.h renamed to libs/mysql/containers/buffers/buffer_sequence_view.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
/// Container class that provides a sequence of buffers to the caller.
2727
/// This is intended for capturing the output from compressors.
2828

29-
#ifndef MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_BUFFER_SEQUENCE_VIEW_H
30-
#define MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_BUFFER_SEQUENCE_VIEW_H
29+
#ifndef MYSQL_CONTAINERS_BUFFERS_BUFFER_SEQUENCE_VIEW_H
30+
#define MYSQL_CONTAINERS_BUFFERS_BUFFER_SEQUENCE_VIEW_H
3131

3232
#include <algorithm> // std::min
3333
#include <cassert> // assert
@@ -38,17 +38,17 @@
3838
#include <vector> // std::vector
3939
#include "mysql/allocators/allocator.h" // mysql::allocators::Allocator
4040

41-
#include "mysql/binlog/event/compression/buffer/buffer_view.h" // buffer::Buffer_view
42-
#include "mysql/binlog/event/compression/buffer/grow_calculator.h" // buffer::Grow_calculator
43-
#include "mysql/binlog/event/compression/buffer/grow_status.h" // buffer::Grow_status
44-
#include "mysql/utils/nodiscard.h" // NODISCARD
41+
#include "mysql/containers/buffers/buffer_view.h" // Buffer_view
42+
#include "mysql/containers/buffers/grow_calculator.h" // Grow_calculator
43+
#include "mysql/containers/buffers/grow_status.h" // Grow_status
44+
#include "mysql/utils/nodiscard.h" // NODISCARD
4545

4646
#include "mysql/binlog/event/wrapper_functions.h" // BAPI_TRACE
4747

48-
/// @addtogroup GroupLibsMysqlBinlogEvent
48+
/// @addtogroup GroupLibsMysqlContainers
4949
/// @{
5050

51-
namespace mysql::binlog::event::compression::buffer {
51+
namespace mysql::containers::buffers {
5252

5353
/// Sequence of memory buffers.
5454
///
@@ -231,8 +231,8 @@ class Buffer_sequence_view {
231231
mutable Size_t m_size;
232232
};
233233

234-
} // namespace mysql::binlog::event::compression::buffer
234+
} // namespace mysql::containers::buffers
235235

236236
/// @}
237237

238-
#endif // MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_BUFFER_SEQUENCE_VIEW_H
238+
#endif // MYSQL_CONTAINERS_BUFFERS_BUFFER_SEQUENCE_VIEW_H

libs/mysql/binlog/event/compression/buffer/buffer_view.h renamed to libs/mysql/containers/buffers/buffer_view.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@
2626
/// Class that groups a pointer+size as one object, without managing
2727
/// the memory for it.
2828

29-
#ifndef MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_BUFFER_VIEW_H
30-
#define MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_BUFFER_VIEW_H
29+
#ifndef MYSQL_CONTAINERS_BUFFERS_BUFFER_VIEW_H
30+
#define MYSQL_CONTAINERS_BUFFERS_BUFFER_VIEW_H
3131

3232
#include <cassert> // assert
3333
#include <string> // std::string
3434
#ifndef NDEBUG
3535
#include <sstream> // std::ostringstream
3636
#endif
3737

38-
/// @addtogroup GroupLibsMysqlBinlogEvent
38+
/// @addtogroup GroupLibsMysqlContainers
3939
/// @{
4040

41-
namespace mysql::binlog::event::compression::buffer {
41+
namespace mysql::containers::buffers {
4242

4343
/// Non-owning view of a memory buffer with a fixed size.
4444
///
@@ -51,7 +51,7 @@ class Buffer_view {
5151
public:
5252
using Char_t = Char_tp;
5353
/// The 'size' type. Keep this equal to
54-
/// buffer::Grow_calculator::Size_t
54+
/// Grow_calculator::Size_t
5555
using Size_t = std::size_t;
5656
using Iterator_t = Char_t *;
5757
using Const_iterator_t = const Char_t *;
@@ -152,8 +152,8 @@ class Buffer_view {
152152
Size_t m_size{0};
153153
};
154154

155-
} // namespace mysql::binlog::event::compression::buffer
155+
} // namespace mysql::containers::buffers
156156

157157
/// @}
158158

159-
#endif // MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_BUFFER_VIEW_H
159+
#endif // MYSQL_CONTAINERS_BUFFERS_BUFFER_VIEW_H

libs/mysql/binlog/event/compression/buffer/grow_calculator.cpp renamed to libs/mysql/containers/buffers/grow_calculator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
along with this program; if not, write to the Free Software
2222
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2323

24-
#include "mysql/binlog/event/compression/buffer/grow_calculator.h"
24+
#include "mysql/containers/buffers/grow_calculator.h"
2525
#include "mysql/binlog/event/math/math.h" // add_bounded
2626
#include "mysql/binlog/event/wrapper_functions.h" // BAPI_TRACE
2727

2828
#include <cassert>
2929

30-
namespace mysql::binlog::event::compression::buffer {
30+
namespace mysql::containers::buffers {
3131

3232
Grow_calculator::Grow_calculator() {
3333
set_max_size(default_max_size);
@@ -68,4 +68,4 @@ Grow_calculator::Result_t Grow_calculator::compute_new_size(
6868
return Result_t(false, new_size);
6969
}
7070

71-
} // namespace mysql::binlog::event::compression::buffer
71+
} // namespace mysql::containers::buffers

libs/mysql/binlog/event/compression/buffer/grow_calculator.h renamed to libs/mysql/containers/buffers/grow_calculator.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323

2424
/// @file grow_calculator.h
2525

26-
#ifndef MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_GROW_CALCULATOR_H
27-
#define MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_GROW_CALCULATOR_H
26+
#ifndef MYSQL_CONTAINERS_BUFFERS_GROW_CALCULATOR_H
27+
#define MYSQL_CONTAINERS_BUFFERS_GROW_CALCULATOR_H
2828

29-
#include "mysql/binlog/event/compression/buffer/grow_constraint.h" // Grow_constraint
29+
#include "mysql/containers/buffers/grow_constraint.h" // Grow_constraint
3030

3131
#include <algorithm> // std::min
3232
#include <limits> // std::numeric_limits
@@ -35,10 +35,10 @@
3535
#include <sstream> // std::stringstream
3636
#endif
3737

38-
/// @addtogroup GroupLibsMysqlBinlogEvent
38+
/// @addtogroup GroupLibsMysqlContainers
3939
/// @{
4040

41-
namespace mysql::binlog::event::compression::buffer {
41+
namespace mysql::containers::buffers {
4242

4343
/// Description of a heuristic to determine how much memory to allocate.
4444
///
@@ -115,8 +115,8 @@ class Grow_calculator : public Grow_constraint {
115115
Result_t compute_new_size(Size_t old_size, Size_t requested_size) const;
116116
};
117117

118-
} // namespace mysql::binlog::event::compression::buffer
118+
} // namespace mysql::containers::buffers
119119

120120
/// @}
121121

122-
#endif /* MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_GROW_CALCULATOR_H */
122+
#endif /* MYSQL_CONTAINERS_BUFFERS_GROW_CALCULATOR_H */

libs/mysql/binlog/event/compression/buffer/grow_constraint.cpp renamed to libs/mysql/containers/buffers/grow_constraint.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
along with this program; if not, write to the Free Software
2222
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2323

24-
#include "mysql/binlog/event/compression/buffer/grow_constraint.h"
24+
#include "mysql/containers/buffers/grow_constraint.h"
2525

2626
#include <cassert>
2727

28-
namespace mysql::binlog::event::compression::buffer {
28+
namespace mysql::containers::buffers {
2929

3030
void Grow_constraint::set_max_size(Size_t max_size) { m_max_size = max_size; }
3131

@@ -57,4 +57,4 @@ Grow_constraint::Size_t Grow_constraint::get_block_size() const {
5757
return m_block_size;
5858
}
5959

60-
} // namespace mysql::binlog::event::compression::buffer
60+
} // namespace mysql::containers::buffers

0 commit comments

Comments
 (0)