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

The base compressor abstract class. More...

#include <base.h>

Inheritance diagram for binary_log::transaction::compression::Compressor:
binary_log::transaction::compression::Base_compressor_decompressor binary_log::transaction::compression::None_comp binary_log::transaction::compression::Zstd_comp

Public Member Functions

virtual void set_compression_level (unsigned int compression_level)=0
 Sets the compression level for this compressor. More...
 
virtual std::tuple< std::size_t, boolcompress (const unsigned char *data, size_t length)=0
 This member function SHALL compress the data provided with the given length. More...
 
- Public Member Functions inherited from binary_log::transaction::compression::Base_compressor_decompressor
 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...
 

Additional Inherited Members

- Protected Attributes inherited from binary_log::transaction::compression::Base_compressor_decompressor
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

The base compressor abstract class.

It establishes the interface for compressors.

Member Function Documentation

◆ compress()

virtual std::tuple<std::size_t, bool> binary_log::transaction::compression::Compressor::compress ( const unsigned char *  data,
size_t  length 
)
pure virtual

This member function SHALL compress the data provided with the given length.

Note that the buffer to store the compressed data must have already have been set through set_buffer.

If the output buffer is not large enough an error shall be returned. The contents of the output buffer may still have been modified in that case.

Parameters
datathe data to compress
lengththe length of the data.
Returns
a tuple containing the bytes not compressed and an error state. If all bytes were decompressed, then it is returned 0 in the first element and false in the second. If not all bytes were compressed, it returns the number of remaining bytes not processed and false on the second element. If there was an error, then the second element returns true and the first elemement returns the number of bytes processed until the error happened.

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

◆ set_compression_level()

virtual void binary_log::transaction::compression::Compressor::set_compression_level ( unsigned int  compression_level)
pure virtual

Sets the compression level for this compressor.

It is only effective if done before opening the compressor. After opening the compressor setting the compression level, it is only effective when the compressor is closed and opened again.

Parameters
compression_levelthe compression level for this compressor.

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


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