MySQL  8.0.22
Source Code Documentation
binary_log::transaction::compression::Base_compressor_decompressor Class Referenceabstract

Base class for compressors and decompressors. More...

#include <base.h>

Inheritance diagram for binary_log::transaction::compression::Base_compressor_decompressor:
binary_log::transaction::compression::Compressor binary_log::transaction::compression::Decompressor binary_log::transaction::compression::None_comp binary_log::transaction::compression::Zstd_comp binary_log::transaction::compression::None_dec binary_log::transaction::compression::Zstd_dec

Public Member Functions

 Base_compressor_decompressor ()
 
virtual ~Base_compressor_decompressor ()
 
virtual type compression_type_code ()=0
 The compression algorithm type. More...
 
virtual bool open ()=0
 This member function SHALL open the compressor or decompressor. More...
 
virtual bool close ()=0
 This member function SHALL close the compressor/decompressor. More...
 
virtual size_t size ()
 This member function returns the size of the compressed/decompressed data. More...
 
virtual std::size_t capacity ()
 This member function returns the capacity of the buffer. More...
 
virtual bool set_buffer (unsigned char *buffer, std::size_t capacity)
 This member function SHALL set the buffer into which the compressor or decompressor shall write the data after it processes the stream. More...
 
virtual std::tuple< unsigned char *, std::size_t, std::size_t > get_buffer ()
 This member function SHALL return the buffer, the size of its data and its capacity. More...
 
virtual bool reserve (std::size_t bytes)
 This member function expands the buffer by a number of bytes. More...
 

Protected Attributes

unsigned char * m_buffer {nullptr}
 The pointer to the buffer holding the data to compress/decompress. More...
 
std::size_t m_buffer_capacity {0}
 The buffer capacity. More...
 
unsigned char * m_buffer_cursor {nullptr}
 A cursor over the buffer. More...
 

Detailed Description

Base class for compressors and decompressors.

It establishes the interface and implements part of the shared behavior.

Constructor & Destructor Documentation

◆ Base_compressor_decompressor()

binary_log::transaction::compression::Base_compressor_decompressor::Base_compressor_decompressor ( )
default

◆ ~Base_compressor_decompressor()

binary_log::transaction::compression::Base_compressor_decompressor::~Base_compressor_decompressor ( )
virtualdefault

Member Function Documentation

◆ capacity()

std::size_t binary_log::transaction::compression::Base_compressor_decompressor::capacity ( )
virtual

This member function returns the capacity of the buffer.

Returns
the capacity of the buffer.

◆ close()

virtual bool binary_log::transaction::compression::Base_compressor_decompressor::close ( )
pure virtual

This member function SHALL close the compressor/decompressor.

Every compressor/decompressor MUST be closed once the stream is over.

Implemented in binary_log::transaction::compression::Zstd_dec, binary_log::transaction::compression::None_dec, binary_log::transaction::compression::Zstd_comp, and binary_log::transaction::compression::None_comp.

◆ compression_type_code()

virtual type binary_log::transaction::compression::Base_compressor_decompressor::compression_type_code ( )
pure virtual

◆ get_buffer()

std::tuple< unsigned char *, std::size_t, std::size_t > binary_log::transaction::compression::Base_compressor_decompressor::get_buffer ( )
virtual

This member function SHALL return the buffer, the size of its data and its capacity.

Returns
a tuple containing the buffer, size and capacity.

◆ open()

virtual bool binary_log::transaction::compression::Base_compressor_decompressor::open ( )
pure virtual

This member function SHALL open the compressor or decompressor.

Every compressor/decompressor must be opened before it is utilized.

Returns
false on success, true otherwise

Implemented in binary_log::transaction::compression::Zstd_dec, binary_log::transaction::compression::None_dec, binary_log::transaction::compression::Zstd_comp, and binary_log::transaction::compression::None_comp.

◆ reserve()

bool binary_log::transaction::compression::Base_compressor_decompressor::reserve ( std::size_t  bytes)
virtual

This member function expands the buffer by a number of bytes.

Expansion is aligned to the block size and it is only done if needed.

Parameters
bytesThe number of bytes to expand the buffer.
Returns
false on success, true otherwise.

◆ set_buffer()

bool binary_log::transaction::compression::Base_compressor_decompressor::set_buffer ( unsigned char *  buffer,
std::size_t  capacity 
)
virtual

This member function SHALL set the buffer into which the compressor or decompressor shall write the data after it processes the stream.

Parameters
bufferthe buffer itself.
capacitythe capacity of the buffer.
Returns
true if something went wrong, false otherwise.

◆ size()

std::size_t binary_log::transaction::compression::Base_compressor_decompressor::size ( )
virtual

This member function returns the size of the compressed/decompressed data.

Returns
the size of the actual data.

Member Data Documentation

◆ m_buffer

unsigned char* binary_log::transaction::compression::Base_compressor_decompressor::m_buffer {nullptr}
protected

The pointer to the buffer holding the data to compress/decompress.

◆ m_buffer_capacity

std::size_t binary_log::transaction::compression::Base_compressor_decompressor::m_buffer_capacity {0}
protected

The buffer capacity.

◆ m_buffer_cursor

unsigned char* binary_log::transaction::compression::Base_compressor_decompressor::m_buffer_cursor {nullptr}
protected

A cursor over the buffer.

It is used internally to calculate the amount of buffer used for instance.


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