MySQL 8.0.40
Source Code Documentation
|
Abstract base class for decompressors. More...
#include <decompressor.h>
Public Types | |
using | Char_t = unsigned char |
using | Size_t = mysqlns::buffer::Buffer_view< Char_t >::Size_t |
using | Managed_buffer_t = mysqlns::buffer::Managed_buffer< Char_t > |
using | Grow_constraint_t = mysqlns::buffer::Grow_constraint |
Public Member Functions | |
Decompressor ()=default | |
Decompressor (const Decompressor &)=delete | |
Decompressor (const Decompressor &&)=delete | |
const Decompressor & | operator= (const Decompressor &)=delete |
const Decompressor & | operator= (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_t > | decompress (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 = mysqlns::buffer::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_t > | do_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... | |
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.
To decompress one or more frames in one piece, use this API as follows:
feed
to provide all inputdecompress
, each time producing as much output as you need.To decompress one or more frames in multiple pieces, use this API as follows:
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.
using binary_log::transaction::compression::Decompressor::Char_t = unsigned char |
using binary_log::transaction::compression::Decompressor::Grow_constraint_t = mysqlns::buffer::Grow_constraint |
|
private |
using binary_log::transaction::compression::Decompressor::Managed_buffer_t = mysqlns::buffer::Managed_buffer<Char_t> |
using binary_log::transaction::compression::Decompressor::Size_t = mysqlns::buffer::Buffer_view<Char_t>::Size_t |
|
default |
|
delete |
|
delete |
|
virtualdefault |
std::pair< Decompress_status, Decompressor::Size_t > binary_log::transaction::compression::Decompressor::decompress | ( | Char_t * | out, |
Size_t | output_size | ||
) |
Decompress an exact, given number of bytes.
out | The output buffer. |
output_size | The number of bytes to decompress. |
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_status binary_log::transaction::compression::Decompressor::decompress | ( | Managed_buffer_t & | out, |
Size_t | output_size | ||
) |
Decompress an exact, given number of bytes.
out | The 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_size | Number of bytes to decompress. |
success | Decompression succeeded. The requested bytes are available in out . |
eof | There were no more bytes to decompress. The out buffer has not been changed and the frame has not been reset. |
truncated | All 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 . |
corrupted | The compression library detected that the data was corrupted. The frame has been reset. |
out_of_memory | The operation failed due to an out of memory error. The frame has been reset. |
exceeds_max_capacity | The 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. |
|
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 binary_log::transaction::compression::None_dec, and binary_log::transaction::compression::Zstd_dec.
|
privatepure virtual |
Implement feed
.
Implemented in binary_log::transaction::compression::None_dec, and binary_log::transaction::compression::Zstd_dec.
|
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 binary_log::transaction::compression::Zstd_dec.
|
privatepure virtual |
Implement get_type_code
.
Implemented in binary_log::transaction::compression::None_dec, and binary_log::transaction::compression::Zstd_dec.
|
privatepure virtual |
Implement do_reset
.
Implemented in binary_log::transaction::compression::None_dec, and binary_log::transaction::compression::Zstd_dec.
|
inline |
Submit data to decompress.
input_data | The buffer of input data that this decompressor will read. |
input_size | The size of the input buffer. |
|
private |
Decompressor::Grow_constraint_t binary_log::transaction::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.
type binary_log::transaction::compression::Decompressor::get_type_code | ( | ) | const |
|
delete |
|
delete |
void binary_log::transaction::compression::Decompressor::reset | ( | ) |
Reset the frame.
This cancels the current frame and starts a new one.