MySQL 9.1.0
Source Code Documentation
mysql::binlog::event::compression::Zstd_comp Class Reference

Compressor class that uses the ZSTD library. More...

#include <zstd_comp.h>

Inheritance diagram for mysql::binlog::event::compression::Zstd_comp:
[legend]

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_compoperator= (const Zstd_comp &rhs)=delete
 
Zstd_compoperator= (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
 
Compressoroperator= (const Compressor &other)=delete
 
Compressoroperator= (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...
 

Detailed Description

Compressor class that uses the ZSTD library.

Member Typedef Documentation

◆ Char_t

◆ Compression_level_t

◆ Managed_buffer_sequence_t

◆ Memory_resource_t

◆ Size_t

Constructor & Destructor Documentation

◆ Zstd_comp() [1/3]

mysql::binlog::event::compression::Zstd_comp::Zstd_comp ( const Memory_resource_t memory_resource = Memory_resource_t())

◆ ~Zstd_comp()

mysql::binlog::event::compression::Zstd_comp::~Zstd_comp ( )
override

◆ Zstd_comp() [2/3]

mysql::binlog::event::compression::Zstd_comp::Zstd_comp ( const Zstd_comp )
delete

◆ Zstd_comp() [3/3]

mysql::binlog::event::compression::Zstd_comp::Zstd_comp ( const Zstd_comp &&  )
delete

Member Function Documentation

◆ destroy()

void mysql::binlog::event::compression::Zstd_comp::destroy ( )
private

Deallocate the ZSTD compression context.

◆ do_compress()

Compress_status mysql::binlog::event::compression::Zstd_comp::do_compress ( Managed_buffer_sequence_t out)
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.

◆ do_feed()

void mysql::binlog::event::compression::Zstd_comp::do_feed ( const Char_t input_data,
Size_t  input_size 
)
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.

◆ do_finish()

Compress_status mysql::binlog::event::compression::Zstd_comp::do_finish ( Managed_buffer_sequence_t out)
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.

◆ do_get_grow_constraint_hint()

Compressor::Grow_constraint_t mysql::binlog::event::compression::Zstd_comp::do_get_grow_constraint_hint ( ) const
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.

◆ do_get_type_code()

type mysql::binlog::event::compression::Zstd_comp::do_get_type_code ( ) const
overrideprivatevirtual

◆ do_reset()

void mysql::binlog::event::compression::Zstd_comp::do_reset ( )
overrideprivatevirtual

Implement reset.

Implements mysql::binlog::event::compression::Compressor.

◆ get_obuf()

Compress_status mysql::binlog::event::compression::Zstd_comp::get_obuf ( Managed_buffer_sequence_t managed_buffer_sequence,
ZSTD_outBuffer_s &  obuf 
)
private

Make the ZSTD buffer point to the next available buffer; allocate one if necessary.

Parameters
[in,out]managed_buffer_sequenceowns the data and manages the growth.
[out]obufZSTD buffer that will be altered to point to the next available byte in buffer_sequence.
Return values
successmanaged_buffer_sequence was not full, or its capacity has been incremented successfully. obuf has been set to point to next available byte.
out_of_memorybuffer_sequence was full and an out of memory error occurred. buffer_sequence has not been modified.
exceeds_max_sizebuffer_sequence was full and at its max capacity. buffer_sequence has not been modified.

◆ move_position()

void mysql::binlog::event::compression::Zstd_comp::move_position ( Managed_buffer_sequence_t managed_buffer_sequence,
Size_t  delta 
)
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.

Parameters
managed_buffer_sequenceThe buffer sequence that has been written to.
deltaThe number of bytes that have been written.

◆ operator=() [1/2]

Zstd_comp & mysql::binlog::event::compression::Zstd_comp::operator= ( const Zstd_comp &&  rhs)
delete

◆ operator=() [2/2]

Zstd_comp & mysql::binlog::event::compression::Zstd_comp::operator= ( const Zstd_comp rhs)
delete

◆ reset_compressor()

void mysql::binlog::event::compression::Zstd_comp::reset_compressor ( )
private

Reset just the ZSTD compressor state, not other state.

◆ set_compression_level()

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.

Parameters
compression_levelthe new compression level.

◆ zstd_mem_res_alloc()

void * mysql::binlog::event::compression::Zstd_comp::zstd_mem_res_alloc ( void *  opaque,
size_t  size 
)
staticprivate

◆ zstd_mem_res_free()

void mysql::binlog::event::compression::Zstd_comp::zstd_mem_res_free ( void *  opaque,
void *  address 
)
staticprivate

Member Data Documentation

◆ default_compression_level

constexpr Compression_level_t mysql::binlog::event::compression::Zstd_comp::default_compression_level = 3
staticconstexpr

The default compression level for this compressor.

◆ m_ctx

ZSTD_CStream* mysql::binlog::event::compression::Zstd_comp::m_ctx {nullptr}
private

The ZSTD compression context.

◆ m_current_compression_level

Compression_level_t mysql::binlog::event::compression::Zstd_comp::m_current_compression_level
private
Initial value:
{
static constexpr Compression_level_t uninitialized_compression_level
Value used to indicate that no compression level has been specified.
Definition: zstd_comp.h:139

Compression level that was set in the m_ctx object.

◆ m_ibuf

ZSTD_inBuffer mysql::binlog::event::compression::Zstd_comp::m_ibuf {nullptr, 0, 0}
private

The input buffer.

◆ m_memory_resource

Memory_resource_t mysql::binlog::event::compression::Zstd_comp::m_memory_resource
private

Instrumented memory allocator object.

◆ m_next_compression_level

Compression_level_t mysql::binlog::event::compression::Zstd_comp::m_next_compression_level {default_compression_level}
private

Compression level that was given in set_compression_level.

◆ m_started

bool mysql::binlog::event::compression::Zstd_comp::m_started {false}
private

True when compress has been called and neither finish nor reset has yet been called.

◆ m_zstd_custom_mem

ZSTD_customMem mysql::binlog::event::compression::Zstd_comp::m_zstd_custom_mem
private

ZSTD memory allocator objects and functions.

◆ type_code

constexpr type mysql::binlog::event::compression::Zstd_comp::type_code = ZSTD
staticconstexpr

◆ uninitialized_compression_level

constexpr Compression_level_t mysql::binlog::event::compression::Zstd_comp::uninitialized_compression_level {0}
staticconstexprprivate

Value used to indicate that no compression level has been specified.


The documentation for this class was generated from the following files: