30#ifndef MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_RW_BUFFER_SEQUENCE_H
31#define MYSQL_BINLOG_EVENT_COMPRESSION_BUFFER_RW_BUFFER_SEQUENCE_H
104template <
class Char_tp =
unsigned char,
105 template <
class Element_tp,
class Allocator_tp>
class Container_tp =
136 assert(begin_arg->data() ==
nullptr);
137 assert(begin_arg->size() == 0);
138 for (
auto it = std::next(begin_arg); it !=
end_arg; ++it) {
139 assert(it->data() !=
nullptr);
140 assert(it->size() != 0);
240 [[maybe_unused]]
int indent)
const {
247 sep = std::string(
",\n") +
248 std::string(
static_cast<std::string::size_type
>(indent * 2),
' ');
251 int next_indent = (indent != 0) ? indent + 1 : 0;
253 ss <<
"Rw_buffer_sequence(ptr=" << (
const void *)
this
255 << sep <<
"read_part="
257 << sep <<
"between_r_and_w="
260 .debug_string(show_contents)
261 << sep <<
"write_part="
274 std::string
debug_string([[maybe_unused]]
bool show_contents =
false)
const {
307 new_position = std::min(new_position,
capacity);
311 assert(position >= 0);
314 while (position > new_position)
322 while (position < new_position) {
324 left, right, new_position - position);
326 assert(position == new_position);
358 auto [write_begin, write_end, write_size] =
get_boundaries(right);
359 if (read_end == write_begin) {
360 auto delta = write_begin->size();
361 auto before_read_end = read_end;
364 before_read_end->size() + delta);
400 auto [write_begin, write_end, write_size] =
get_boundaries(right);
401 assert(read_end != write_begin);
402 assert(read_end->data() ==
nullptr);
403 assert(read_end != read_begin);
406 *write_begin = *read_end;
408 auto delta = write_begin->size();
429 auto [write_begin, write_end, write_size] =
get_boundaries(right);
430 assert(read_end != write_begin);
431 assert(read_end->data() ==
nullptr);
432 if (write_begin->size() <= limit) {
442 auto delta = write_begin->size();
443 *read_end = *write_begin;
464 Buffer_view_t(write_begin->data() + limit, write_begin->size() - limit);
479 return std::make_tuple(buffer_sequence_view.
begin(),
480 buffer_sequence_view.
end(),
481 buffer_sequence_view.
size());
Container class that provides a sequence of buffers to the caller.
Class that groups a pointer+size as one object, without managing the memory for it.
Sequence of memory buffers.
Definition: buffer_sequence_view.h:72
Container_tp< Buffer_view_t, Buffer_allocator_t > Container_t
Definition: buffer_sequence_view.h:79
Iterator_t begin()
Iterator to the first buffer.
Definition: buffer_sequence_view.h:117
Size_t size() const
Return the total size of all buffers.
Definition: buffer_sequence_view.h:164
Buffer_view< Char_t > Buffer_view_t
Definition: buffer_sequence_view.h:76
typename std::conditional< const_tp, Const_iterator_t, typename Container_t::iterator >::type Iterator_t
Definition: buffer_sequence_view.h:83
std::string debug_string(bool show_contents=false, int indent=0) const
In debug mode, return a string that describes the internal structure of this object,...
Definition: buffer_sequence_view.h:185
Iterator_t end()
Iterator to the last buffer.
Definition: buffer_sequence_view.h:120
std::size_t Size_t
Definition: buffer_sequence_view.h:75
Char_tp Char_t
Definition: buffer_sequence_view.h:74
typename Container_t::const_iterator Const_iterator_t
Definition: buffer_sequence_view.h:80
mysql::binlog::event::resource::Allocator< Buffer_view_t > Buffer_allocator_t
Definition: buffer_sequence_view.h:78
Non-owning manager for a fixed sequence of memory buffers, which is split into a read part and a writ...
Definition: rw_buffer_sequence.h:107
Buffer_sequence_view< Char_tp, Container_tp > Buffer_sequence_view_t
Definition: rw_buffer_sequence.h:109
std::string debug_string(bool show_contents=false) const
In debug mode, return a string that describes the internal structure of this object,...
Definition: rw_buffer_sequence.h:274
Buffer_sequence_view< Char_tp, Container_tp, true > Const_buffer_sequence_view_t
Definition: rw_buffer_sequence.h:120
Rw_buffer_sequence & operator=(Rw_buffer_sequence &&)=delete
const Buffer_sequence_view_t & write_part() const
Return a const reference to the write part.
Definition: rw_buffer_sequence.h:225
Size_t capacity() const
Return the current size, i.e., total size of all buffers.
Definition: rw_buffer_sequence.h:216
typename Buffer_sequence_view_t::Iterator_t Iterator_t
Definition: rw_buffer_sequence.h:117
Buffer_sequence_view_t & write_part()
Return a non-const reference to the write part.
Definition: rw_buffer_sequence.h:228
void move_position(Difference_t delta)
Move the position left or right, relative to the current position.
Definition: rw_buffer_sequence.h:207
void increase_position(Size_t delta)
Move the position right, relative to the current position.
Definition: rw_buffer_sequence.h:187
Rw_buffer_sequence & operator=(Rw_buffer_sequence &)=delete
static Size_t move_position_at_most_one_buffer_right(Buffer_sequence_view_t &left, Buffer_sequence_view_t &right, Size_t limit)
Move the position right by whatever is smaller: the given number, or one buffer; splits the buffer if...
Definition: rw_buffer_sequence.h:425
Rw_buffer_sequence(Rw_buffer_sequence &)=delete
Buffer_sequence_view_t & read_part()
Return a non-const reference to the read part.
Definition: rw_buffer_sequence.h:222
const Buffer_sequence_view_t & read_part() const
Return a const reference to the read part.
Definition: rw_buffer_sequence.h:219
typename Buffer_sequence_view_t::Buffer_allocator_t Buffer_allocator_t
Definition: rw_buffer_sequence.h:115
void set_position(Size_t new_position)
Set the specified absolute position.
Definition: rw_buffer_sequence.h:168
static Size_t merge_if_split(Buffer_sequence_view_t &left, Buffer_sequence_view_t &right)
If a buffer is split between the read and write parts, glue the pieces together again and include the...
Definition: rw_buffer_sequence.h:355
typename Buffer_sequence_view_t::Char_t Char_t
Definition: rw_buffer_sequence.h:110
typename Buffer_sequence_view_t::Container_t Container_t
Definition: rw_buffer_sequence.h:116
Buffer_sequence_view_t m_read_part
buffer_sequence_view for the (leading) read segment.
Definition: rw_buffer_sequence.h:486
Buffer_sequence_view_t m_write_part
buffer_sequence_view for the (trailing) write segment.
Definition: rw_buffer_sequence.h:488
typename Buffer_sequence_view_t::Size_t Size_t
Definition: rw_buffer_sequence.h:111
static void set_position(Size_t new_position, Buffer_sequence_view_t &left, Buffer_sequence_view_t &right)
Move the position to the given, absolute position.
Definition: rw_buffer_sequence.h:300
static Size_t move_position_one_buffer_left(Buffer_sequence_view_t &left, Buffer_sequence_view_t &right)
Move the position exactly one buffer left, assuming no buffer is split.
Definition: rw_buffer_sequence.h:397
virtual ~Rw_buffer_sequence()=default
std::ptrdiff_t Difference_t
Definition: rw_buffer_sequence.h:112
Rw_buffer_sequence(Rw_buffer_sequence &&)=delete
typename Buffer_sequence_view_t::Const_iterator_t Const_iterator_t
Definition: rw_buffer_sequence.h:118
typename Buffer_sequence_view_t::Buffer_view_t Buffer_view_t
Definition: rw_buffer_sequence.h:113
Rw_buffer_sequence(Iterator_t begin_arg, Iterator_t end_arg)
Construct a new Rw_buffer_sequence from given endpoint iterators, with position 0.
Definition: rw_buffer_sequence.h:131
static std::tuple< Iterator_t, Iterator_t, Size_t > get_boundaries(Buffer_sequence_view_t &buffer_sequence_view)
Return the beginning, end, and size of the read and write parts.
Definition: rw_buffer_sequence.h:477
virtual std::string debug_string(bool show_contents, int indent) const
In debug mode, return a string that describes the internal structure of this object,...
Definition: rw_buffer_sequence.h:239
Allocator class that uses a polymorphic Memory_resource to allocate memory.
Definition: buffer_sequence_view.h:51
const char * begin(const char *const c)
Definition: base64.h:44
size_t size(const char *const c)
Definition: base64.h:46
Definition: gcs_xcom_synode.h:64
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2870
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2874
static task_arg end_arg()
Definition: task.h:207
Contains wrapper functions for memory allocation and deallocation.
#define BAPI_TRACE
Definition: wrapper_functions.h:65