MySQL 9.1.0
Source Code Documentation
|
Class that manages dynamic buffers. More...
#include <dyn0buf.h>
Classes | |
class | block_t |
Public Member Functions | |
typedef | UT_LIST_NODE_T (block_t) block_node_t |
typedef | UT_LIST_BASE_NODE_T (block_t, m_node) block_list_t |
dyn_buf_t () | |
Default constructor. More... | |
~dyn_buf_t () | |
Destructor. More... | |
void | erase () |
Reset the buffer vector. More... | |
byte * | open (ulint size) |
Makes room on top and returns a pointer to a buffer in it. More... | |
void | close (const byte *ptr) |
Closes the buffer returned by open. More... | |
template<typename Type > | |
Type | push (uint32_t size) |
Makes room on top and returns a pointer to the added element. More... | |
void | push (const byte *ptr, uint32_t len) |
Pushes n bytes. More... | |
template<typename Type > | |
const Type | at (ulint pos) const |
Returns a pointer to an element in the buffer. More... | |
template<typename Type > | |
Type | at (ulint pos) |
Returns a pointer to an element in the buffer. More... | |
ulint | size () const |
Returns the size of the total stored data. More... | |
template<typename Functor > | |
bool | for_each_block (Functor &functor) const |
Iterate over each block and call the functor. More... | |
template<typename Functor > | |
bool | for_each_block_in_reverse (Functor &functor) const |
Iterate over all the blocks in reverse and call the iterator. More... | |
block_t * | front () |
bool | is_small () const |
Static Public Attributes | |
static constexpr auto | MAX_DATA_SIZE = block_t::MAX_DATA_SIZE |
Private Member Functions | |
dyn_buf_t (dyn_buf_t &&)=delete | |
dyn_buf_t (const dyn_buf_t &)=delete | |
dyn_buf_t & | operator= (dyn_buf_t &&)=delete |
dyn_buf_t & | operator= (const dyn_buf_t &)=delete |
void | push_back (block_t *block) |
Add the block to the end of the list. More... | |
block_t * | back () |
bool | has_space (ulint size) const |
bool | has_space (ulint size) |
block_t * | find (ulint &pos) |
Find the block that contains the pos. More... | |
block_t * | add_block () |
Allocate and add a new block to m_list. More... | |
Private Attributes | |
mem_heap_t * | m_heap |
Heap to use for memory allocation. More... | |
block_list_t | m_list |
Allocated blocks. More... | |
ulint | m_size |
Total size used by all blocks. More... | |
block_t | m_first_block |
The default block, should always be the first element. More... | |
Class that manages dynamic buffers.
It uses a UT_LIST of dyn_buf_t::block_t instances. We don't use STL containers in order to avoid the overhead of heap calls. Using a custom memory allocator doesn't solve the problem either because we have to get the memory from somewhere. We can't use the block_t::m_data as the backend for the custom allocator because we would like the data in the blocks to be contiguous.
Default constructor.
|
privatedelete |
|
privatedelete |
|
inlineprivate |
Allocate and add a new block to m_list.
|
inline |
Returns a pointer to an element in the buffer.
non const version.
pos | position of element in bytes from start |
|
inline |
Returns a pointer to an element in the buffer.
const version.
pos | position of element in bytes from start |
|
inline |
Closes the buffer returned by open.
ptr | end of used space |
|
inline |
Reset the buffer vector.
|
inlineprivate |
Find the block that contains the pos.
pos | absolute offset, it is updated to make it relative to the block |
|
inline |
Iterate over each block and call the functor.
|
inline |
Iterate over all the blocks in reverse and call the iterator.
|
inlineprivate |
|
inlineprivate |
|
inline |
Makes room on top and returns a pointer to a buffer in it.
After copying the elements, the caller must close the buffer using close().
size | in bytes of the buffer; MUST be <= MAX_DATA_SIZE! |
|
privatedelete |
|
privatedelete |
|
inline |
Pushes n bytes.
ptr | string to write |
len | string length |
|
inline |
Makes room on top and returns a pointer to the added element.
The caller must copy the element to the pointer returned.
size | in bytes of the element |
|
inlineprivate |
Add the block to the end of the list.
Returns the size of the total stored data.
typedef dyn_buf_t< SIZE >::UT_LIST_BASE_NODE_T | ( | block_t | , |
m_node | |||
) |
The default block, should always be the first element.
This is for backwards compatibility and to avoid an extra heap allocation for small REDO log records
|
private |
Heap to use for memory allocation.
|
private |
Allocated blocks.
Total size used by all blocks.
|
staticconstexpr |