MySQL 9.1.0
Source Code Documentation
|
Compressor class that uses the ZSTD library. More...
#include <zstd_comp.h>
Public Types | |
using | Memory_resource_t = mysql::allocators::Memory_resource |
using | Compression_level_t = int |
using | Char_t = Managed_buffer_sequence_t::Char_t |
using | Managed_buffer_sequence_t = mysql::containers::buffers::Managed_buffer_sequence<> |
using | Size_t = Managed_buffer_sequence_t::Size_t |
Public Types inherited from mysql::binlog::event::compression::Compressor | |
using | Managed_buffer_sequence_t = mysql::containers::buffers::Managed_buffer_sequence<> |
using | Char_t = Managed_buffer_sequence_t::Char_t |
using | Size_t = Managed_buffer_sequence_t::Size_t |
using | Grow_constraint_t = mysql::containers::buffers::Grow_constraint |
Public Member Functions | |
Zstd_comp (const Memory_resource_t &memory_resource=Memory_resource_t()) | |
~Zstd_comp () override | |
Zstd_comp (const Zstd_comp &)=delete | |
Zstd_comp (const Zstd_comp &&)=delete | |
Zstd_comp & | operator= (const Zstd_comp &rhs)=delete |
Zstd_comp & | operator= (const Zstd_comp &&rhs)=delete |
void | set_compression_level (Compression_level_t compression_level) |
Set the compression level for this compressor. More... | |
Public Member Functions inherited from mysql::binlog::event::compression::Compressor | |
Compressor ()=default | |
Compressor (const Compressor &other)=delete | |
Compressor (Compressor &&other)=delete | |
Compressor & | operator= (const Compressor &other)=delete |
Compressor & | operator= (Compressor &&other)=delete |
virtual | ~Compressor ()=default |
type | get_type_code () const |
void | reset () |
Reset the frame. More... | |
template<class Input_char_t > | |
void | feed (const Input_char_t *input_data, Size_t input_size) |
Submit data to be compressed. More... | |
Compress_status | compress (Managed_buffer_sequence_t &out) |
Consume all input previously given in the feed function. More... | |
Compress_status | finish (Managed_buffer_sequence_t &out) |
Consume all input, produce all output, and end the frame. More... | |
Grow_constraint_t | get_grow_constraint_hint () const |
Return a Grow_constraint that may be used with the Managed_buffer_sequence storing the output, in order to optimize memory usage for a particular compression algorithm. More... | |
void | set_pledged_input_size (Size_t size) |
Declare that the input size will be exactly as given. More... | |
Size_t | get_pledged_input_size () const |
Return the size previously provided to set_pledged_input_size , or pledged_input_size_unset if no pledged size has been set. More... | |
Static Public Attributes | |
static constexpr type | type_code = ZSTD |
static constexpr Compression_level_t | default_compression_level = 3 |
The default compression level for this compressor. More... | |
Static Public Attributes inherited from mysql::binlog::event::compression::Compressor | |
static constexpr Size_t | pledged_input_size_unset |
Private Member Functions | |
type | do_get_type_code () const override |
void | do_reset () override |
Implement reset . More... | |
void | do_feed (const Char_t *input_data, Size_t input_size) override |
Implement feed . More... | |
Compress_status | do_compress (Managed_buffer_sequence_t &out) override |
Implement compress . More... | |
Compress_status | do_finish (Managed_buffer_sequence_t &out) override |
Implement finish . More... | |
Grow_constraint_t | do_get_grow_constraint_hint () const override |
Implement get_grow_constraint_hint . More... | |
void | destroy () |
Deallocate the ZSTD compression context. More... | |
void | reset_compressor () |
Reset just the ZSTD compressor state, not other state. More... | |
Compress_status | get_obuf (Managed_buffer_sequence_t &managed_buffer_sequence, ZSTD_outBuffer_s &obuf) |
Make the ZSTD buffer point to the next available buffer; allocate one if necessary. More... | |
void | move_position (Managed_buffer_sequence_t &managed_buffer_sequence, Size_t delta) |
Account for having written to the output buffer. More... | |
Static Private Member Functions | |
static void * | zstd_mem_res_alloc (void *opaque, size_t size) |
static void | zstd_mem_res_free (void *opaque, void *address) |
Private Attributes | |
ZSTD_CStream * | m_ctx {nullptr} |
The ZSTD compression context. More... | |
ZSTD_inBuffer | m_ibuf {nullptr, 0, 0} |
The input buffer. More... | |
bool | m_started {false} |
True when compress has been called and neither finish nor reset has yet been called. More... | |
Compression_level_t | m_current_compression_level |
Compression level that was set in the m_ctx object. More... | |
Compression_level_t | m_next_compression_level {default_compression_level} |
Compression level that was given in set_compression_level . More... | |
Memory_resource_t | m_memory_resource |
Instrumented memory allocator object. More... | |
ZSTD_customMem | m_zstd_custom_mem |
ZSTD memory allocator objects and functions. More... | |
Static Private Attributes | |
static constexpr Compression_level_t | uninitialized_compression_level {0} |
Value used to indicate that no compression level has been specified. More... | |
Compressor class that uses the ZSTD library.
using mysql::binlog::event::compression::Compressor::Managed_buffer_sequence_t = mysql::containers::buffers::Managed_buffer_sequence<> |
using mysql::binlog::event::compression::Zstd_comp::Memory_resource_t = mysql::allocators::Memory_resource |
mysql::binlog::event::compression::Zstd_comp::Zstd_comp | ( | const Memory_resource_t & | memory_resource = Memory_resource_t() | ) |
|
override |
|
delete |
|
delete |
|
private |
Deallocate the ZSTD compression context.
|
overrideprivatevirtual |
Implement compress
.
This differs from compress
in that it does not have to reset the frame when returning out_of_memory; the caller does that.
Implements mysql::binlog::event::compression::Compressor.
|
overrideprivatevirtual |
Implement feed
.
This differs from feed
in that it does not have to reset the frame when returning out_of_memory; the caller does that.
Implements mysql::binlog::event::compression::Compressor.
|
overrideprivatevirtual |
Implement finish
.
This differs from finish
in that it does not have to reset the frame when returning out_of_memory; the caller does that.
Implementations may assume that compress
has been called, since finish
does that.
Implements mysql::binlog::event::compression::Compressor.
|
overrideprivatevirtual |
Implement get_grow_constraint_hint
.
In this base class, the function returns a default-constructed Grow_constraint, i.e., one which does not limit the Grow_calculator.
Reimplemented from mysql::binlog::event::compression::Compressor.
|
overrideprivatevirtual |
Implements mysql::binlog::event::compression::Compressor.
|
overrideprivatevirtual |
Implement reset
.
Implements mysql::binlog::event::compression::Compressor.
|
private |
Make the ZSTD buffer point to the next available buffer; allocate one if necessary.
[in,out] | managed_buffer_sequence | owns the data and manages the growth. |
[out] | obuf | ZSTD buffer that will be altered to point to the next available byte in buffer_sequence. |
success | managed_buffer_sequence was not full, or its capacity has been incremented successfully. obuf has been set to point to next available byte. |
out_of_memory | buffer_sequence was full and an out of memory error occurred. buffer_sequence has not been modified. |
exceeds_max_size | buffer_sequence was full and at its max capacity. buffer_sequence has not been modified. |
|
private |
Account for having written to the output buffer.
This moves the read/write boundary in the Managed_buffer_sequence, and also increments m_total_output_size.
managed_buffer_sequence | The buffer sequence that has been written to. |
delta | The number of bytes that have been written. |
|
delete |
|
private |
Reset just the ZSTD compressor state, not other state.
void mysql::binlog::event::compression::Zstd_comp::set_compression_level | ( | Compression_level_t | compression_level | ) |
Set the compression level for this compressor.
This function may be invoked at any time, but will only take effect the next time a new frame starts, i.e., at the first call to feed
after the frame has been reset.
compression_level | the new compression level. |
|
staticprivate |
|
staticprivate |
|
staticconstexpr |
The default compression level for this compressor.
|
private |
The ZSTD compression context.
|
private |
Compression level that was set in the m_ctx
object.
|
private |
The input buffer.
|
private |
Instrumented memory allocator object.
|
private |
Compression level that was given in set_compression_level
.
|
private |
True when compress
has been called and neither finish
nor reset
has yet been called.
|
private |
ZSTD memory allocator objects and functions.
|
staticconstexprprivate |
Value used to indicate that no compression level has been specified.