MySQL 9.1.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
mysql::binlog::event::compression::Decompressor Class Referenceabstract

Abstract base class for decompressors. More...

#include <decompressor.h>

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

Public Types

using Char_t = unsigned char
 
using Size_t = mysql::containers::buffers::Buffer_view< Char_t >::Size_t
 
using Managed_buffer_t = mysql::containers::buffers::Managed_buffer< Char_t >
 
using Grow_constraint_t = mysql::containers::buffers::Grow_constraint
 

Public Member Functions

 Decompressor ()=default
 
 Decompressor (const Decompressor &)=delete
 
 Decompressor (const Decompressor &&)=delete
 
const Decompressoroperator= (const Decompressor &)=delete
 
const Decompressoroperator= (const Decompressor &&)=delete
 
virtual ~Decompressor ()=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 decompress. More...
 
Decompress_status decompress (Managed_buffer_t &out, Size_t output_size)
 Decompress an exact, given number of bytes. More...
 
std::pair< Decompress_status, Size_tdecompress (Char_t *out, Size_t output_size)
 Decompress an exact, given number of bytes. More...
 
Grow_constraint_t get_grow_constraint_hint () const
 Return a Grow_constraint that may be used with the Managed_buffer storing the output, in order to optimize memory usage for a particular compression algorithm. More...
 

Private Types

using Grow_status_t = mysql::containers::buffers::Grow_status
 

Private Member Functions

virtual type do_get_type_code () const =0
 Implement get_type_code. More...
 
virtual void do_reset ()=0
 Implement do_reset. More...
 
void feed_char_t (const Char_t *input_data, Size_t input_size)
 
virtual void do_feed (const Char_t *input_data, Size_t input_size)=0
 Implement feed. More...
 
virtual std::pair< Decompress_status, Size_tdo_decompress (Char_t *out, Size_t output_size)=0
 Implement decompress. More...
 
virtual Grow_constraint_t do_get_grow_constraint_hint () const
 Implement get_grow_constraint_hint. More...
 

Detailed Description

Abstract base class for decompressors.

Each subclass normally corresponds to a compression algorithm, and maintains the algorithm-specific state for it.

An instance of this class can be reused to decompress several different frames. Each frame input may be split into multiple pieces.

See also
Compressor.

To decompress one or more frames in one piece, use this API as follows:

  1. Call feed to provide all input
  2. Repeatedly call decompress, each time producing as much output as you need.

To decompress one or more frames in multiple pieces, use this API as follows:

  1. Repeatedly call decompress, each time producing as much output as you need. Whenever it returns eof or truncated, call feed to provide more input, and try again.

This class uses a buffer::Managed_buffer to store output.

Member Typedef Documentation

◆ Char_t

◆ Grow_constraint_t

◆ Grow_status_t

◆ Managed_buffer_t

◆ Size_t

Constructor & Destructor Documentation

◆ Decompressor() [1/3]

mysql::binlog::event::compression::Decompressor::Decompressor ( )
default

◆ Decompressor() [2/3]

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

◆ Decompressor() [3/3]

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

◆ ~Decompressor()

virtual mysql::binlog::event::compression::Decompressor::~Decompressor ( )
virtualdefault

Member Function Documentation

◆ decompress() [1/2]

std::pair< Decompress_status, Decompressor::Size_t > mysql::binlog::event::compression::Decompressor::decompress ( Char_t out,
Size_t  output_size 
)

Decompress an exact, given number of bytes.

Parameters
outThe output buffer.
output_sizeThe number of bytes to decompress.
Returns
a pair where the first component is a Decompress_status value and the second component is the number of bytes that were successfully stored in out. The Decompress_status has the same possible values as for decompress(Managed_buffer_t, output_size), except it cannot take the value exceeds_max_capacity. The size will be equal to output_size if the status is success; strictly between 0 and output_size if the status is truncated; and 0 for the other cases.

◆ decompress() [2/2]

Decompress_status mysql::binlog::event::compression::Decompressor::decompress ( Managed_buffer_t out,
Size_t  output_size 
)

Decompress an exact, given number of bytes.

Parameters
outThe output buffer. This function first grows the write part of out to at least output_size bytes, then decompresses into the write part, and then moves the decompressed bytes from the beginning of the write part to the end of the read part.
output_sizeNumber of bytes to decompress.
Return values
successDecompression succeeded. The requested bytes are available in out.
eofThere were no more bytes to decompress. The out buffer has not been changed and the frame has not been reset.
truncatedAll input was consumed, but produced less output than requested. The out buffer has been changed and the frame has not been reset. The caller may resume decompression after calling feed.
corruptedThe compression library detected that the data was corrupted. The frame has been reset.
out_of_memoryThe operation failed due to an out of memory error. The frame has been reset.
exceeds_max_capacityThe requested size exceeds the maximium capacity configured for the Managed_buffer. The out buffer has not been changed and the frame has not been reset. The caller may resume decompression after increasing the capacity, or resetting the buffer (perhaps after moving the data elsewhere), or using a different output buffer, or similar.

◆ do_decompress()

virtual std::pair< Decompress_status, Size_t > mysql::binlog::event::compression::Decompressor::do_decompress ( Char_t out,
Size_t  output_size 
)
privatepure virtual

Implement decompress.

This differs from decompress in that it does not have to reset the frame when returning out_of_memory or corrupted; the caller does that.

Implemented in mysql::binlog::event::compression::None_dec, and mysql::binlog::event::compression::Zstd_dec.

◆ do_feed()

virtual void mysql::binlog::event::compression::Decompressor::do_feed ( const Char_t input_data,
Size_t  input_size 
)
privatepure virtual

◆ do_get_grow_constraint_hint()

Decompressor::Grow_constraint_t mysql::binlog::event::compression::Decompressor::do_get_grow_constraint_hint ( ) const
privatevirtual

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 in mysql::binlog::event::compression::Zstd_dec.

◆ do_get_type_code()

virtual type mysql::binlog::event::compression::Decompressor::do_get_type_code ( ) const
privatepure virtual

◆ do_reset()

virtual void mysql::binlog::event::compression::Decompressor::do_reset ( )
privatepure virtual

◆ feed()

template<class Input_char_t >
void mysql::binlog::event::compression::Decompressor::feed ( const Input_char_t *  input_data,
Size_t  input_size 
)
inline

Submit data to decompress.

Parameters
input_dataThe buffer of input data that this decompressor will read.
input_sizeThe size of the input buffer.

◆ feed_char_t()

void mysql::binlog::event::compression::Decompressor::feed_char_t ( const Char_t input_data,
Size_t  input_size 
)
private

◆ get_grow_constraint_hint()

Decompressor::Grow_constraint_t mysql::binlog::event::compression::Decompressor::get_grow_constraint_hint ( ) const

Return a Grow_constraint that may be used with the Managed_buffer storing the output, in order to optimize memory usage for a particular compression algorithm.

◆ get_type_code()

type mysql::binlog::event::compression::Decompressor::get_type_code ( ) const
Returns
the compression type.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ reset()

void mysql::binlog::event::compression::Decompressor::reset ( )

Reset the frame.

This cancels the current frame and starts a new one.


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