MySQL 8.0.40
Source Code Documentation
binary_log::transaction::compression::Zstd_comp Class Reference

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

#include <zstd_comp.h>

Inheritance diagram for binary_log::transaction::compression::Zstd_comp:
[legend]

Public Types

using Compression_level_t = int
 
using Char_t = Managed_buffer_sequence_t::Char_t
 
using Managed_buffer_sequence_t = mysqlns::buffer::Managed_buffer_sequence<>
 
using Size_t = Managed_buffer_sequence_t::Size_t
 
- Public Types inherited from binary_log::transaction::compression::Compressor
using Managed_buffer_sequence_t = mysqlns::buffer::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 = mysqlns::buffer::Grow_constraint
 

Public Member Functions

 Zstd_comp ()=default
 
 ~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 binary_log::transaction::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 binary_log::transaction::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...
 

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...
 

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

using binary_log::transaction::compression::Compressor::Char_t = Managed_buffer_sequence_t::Char_t

◆ Compression_level_t

◆ Managed_buffer_sequence_t

◆ Size_t

using binary_log::transaction::compression::Compressor::Size_t = Managed_buffer_sequence_t::Size_t

Constructor & Destructor Documentation

◆ Zstd_comp() [1/3]

binary_log::transaction::compression::Zstd_comp::Zstd_comp ( )
default

◆ ~Zstd_comp()

binary_log::transaction::compression::Zstd_comp::~Zstd_comp ( )
override

◆ Zstd_comp() [2/3]

binary_log::transaction::compression::Zstd_comp::Zstd_comp ( const Zstd_comp )
delete

◆ Zstd_comp() [3/3]

binary_log::transaction::compression::Zstd_comp::Zstd_comp ( const Zstd_comp &&  )
delete

Member Function Documentation

◆ destroy()

void binary_log::transaction::compression::Zstd_comp::destroy ( )
private

Deallocate the ZSTD compression context.

◆ do_compress()

Compress_status binary_log::transaction::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 binary_log::transaction::compression::Compressor.

◆ do_feed()

void binary_log::transaction::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 binary_log::transaction::compression::Compressor.

◆ do_finish()

Compress_status binary_log::transaction::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 binary_log::transaction::compression::Compressor.

◆ do_get_grow_constraint_hint()

Compressor::Grow_constraint_t binary_log::transaction::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 binary_log::transaction::compression::Compressor.

◆ do_get_type_code()

type binary_log::transaction::compression::Zstd_comp::do_get_type_code ( ) const
overrideprivatevirtual

◆ do_reset()

void binary_log::transaction::compression::Zstd_comp::do_reset ( )
overrideprivatevirtual

◆ get_obuf()

Compress_status binary_log::transaction::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 binary_log::transaction::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 & binary_log::transaction::compression::Zstd_comp::operator= ( const Zstd_comp &&  rhs)
delete

◆ operator=() [2/2]

Zstd_comp & binary_log::transaction::compression::Zstd_comp::operator= ( const Zstd_comp rhs)
delete

◆ reset_compressor()

void binary_log::transaction::compression::Zstd_comp::reset_compressor ( )
private

Reset just the ZSTD compressor state, not other state.

◆ set_compression_level()

void binary_log::transaction::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.

Member Data Documentation

◆ default_compression_level

constexpr Compression_level_t binary_log::transaction::compression::Zstd_comp::default_compression_level = 3
staticconstexpr

The default compression level for this compressor.

◆ m_ctx

ZSTD_CStream* binary_log::transaction::compression::Zstd_comp::m_ctx {nullptr}
private

The ZSTD compression context.

◆ m_current_compression_level

Compression_level_t binary_log::transaction::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:136

Compression level that was set in the m_ctx object.

◆ m_ibuf

ZSTD_inBuffer binary_log::transaction::compression::Zstd_comp::m_ibuf {nullptr, 0, 0}
private

The input buffer.

◆ m_next_compression_level

Compression_level_t binary_log::transaction::compression::Zstd_comp::m_next_compression_level {default_compression_level}
private

Compression level that was given in set_compression_level.

◆ m_started

bool binary_log::transaction::compression::Zstd_comp::m_started {false}
private

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

◆ type_code

constexpr type binary_log::transaction::compression::Zstd_comp::type_code = ZSTD
staticconstexpr

◆ uninitialized_compression_level

constexpr Compression_level_t binary_log::transaction::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: