MySQL 8.4.0
Source Code Documentation
Gcs_message_stage_lz4 Class Reference

This class implements LZ4 compression. More...

#include <gcs_message_stage_lz4.h>

Inheritance diagram for Gcs_message_stage_lz4:
[legend]

Public Member Functions

Gcs_message_stage::stage_status skip_apply (uint64_t const &original_payload_size) const override
 Check if the apply operation which affects outgoing packets should be executed (i.e. More...
 
std::unique_ptr< Gcs_stage_metadataget_stage_header () override
 
 Gcs_message_stage_lz4 ()
 Creates an instance of the stage with the default threshold in bytes set. More...
 
 Gcs_message_stage_lz4 (bool enabled, unsigned long long compress_threshold)
 Creates an instance of the stage with the given threshold in bytes. More...
 
 ~Gcs_message_stage_lz4 () override=default
 
Stage_code get_stage_code () const override
 Return the unique stage code. More...
 
void set_threshold (unsigned long long threshold)
 Sets the threshold in bytes after which compression kicks in. More...
 
- Public Member Functions inherited from Gcs_message_stage
 Gcs_message_stage ()
 
 Gcs_message_stage (bool enabled)
 
virtual ~Gcs_message_stage ()=default
 
std::pair< bool, std::vector< Gcs_packet > > apply (Gcs_packet &&packet)
 Apply some transformation to the outgoing packet, and return a set of one, or more, transformed packets. More...
 
std::pair< Gcs_pipeline_incoming_result, Gcs_packetrevert (Gcs_packet &&packet)
 Revert some transformation from the incoming packet, and return one, or none, transformed packet. More...
 
bool is_enabled () const
 Return whether the message stage is enabled or not. More...
 
virtual bool update_members_information (const Gcs_member_identifier &, const Gcs_xcom_nodes &)
 Update the list of members in the group as this may be required by some stages in the communication pipeline. More...
 
virtual Gcs_xcom_synode_set get_snapshot () const
 
void set_enabled (bool is_enabled)
 Enable or disable the message stage. More...
 

Static Public Member Functions

static constexpr unsigned long long max_input_compression () noexcept
 Return the maximum payload size in bytes that can be compressed. More...
 

Static Public Attributes

static constexpr unsigned long long DEFAULT_THRESHOLD = 1024
 The default threshold value in bytes. More...
 

Protected Member Functions

std::pair< bool, std::vector< Gcs_packet > > apply_transformation (Gcs_packet &&packet) override
 Implements the logic of this stage's transformation to the packet, and returns a set of one, or more, transformed packets. More...
 
std::pair< Gcs_pipeline_incoming_result, Gcs_packetrevert_transformation (Gcs_packet &&packet) override
 Implements the logic to revert this stage's transformation to the packet, and returns one, or none, transformed packet. More...
 
Gcs_message_stage::stage_status skip_revert (const Gcs_packet &packet) const override
 Check if the revert operation which affects incoming packets should be executed (i.e. More...
 
- Protected Member Functions inherited from Gcs_message_stage
void encode (unsigned char *header, unsigned short header_length, unsigned long long old_payload_length)
 Encode the fixed part of the associated dynamic header information into the header buffer. More...
 
void decode (const unsigned char *header, unsigned short *header_length, unsigned long long *old_payload_length)
 Decode the fixed part of the associated dynamic header information from the header buffer. More...
 

Private Attributes

unsigned long long m_threshold
 This marks the threshold in bytes above which a message gets compressed. More...
 

Additional Inherited Members

- Public Types inherited from Gcs_message_stage
enum class  stage_status : unsigned int { apply , skip , abort }
 

Detailed Description

This class implements LZ4 compression.

It is a stateless service class, thence it is thread safe.

Constructor & Destructor Documentation

◆ Gcs_message_stage_lz4() [1/2]

Gcs_message_stage_lz4::Gcs_message_stage_lz4 ( )
inlineexplicit

Creates an instance of the stage with the default threshold in bytes set.

◆ Gcs_message_stage_lz4() [2/2]

Gcs_message_stage_lz4::Gcs_message_stage_lz4 ( bool  enabled,
unsigned long long  compress_threshold 
)
inlineexplicit

Creates an instance of the stage with the given threshold in bytes.

Parameters
enabledenables this message stage
compress_thresholdmessages with the payload larger than compress_threshold in bytes are compressed.

◆ ~Gcs_message_stage_lz4()

Gcs_message_stage_lz4::~Gcs_message_stage_lz4 ( )
overridedefault

Member Function Documentation

◆ apply_transformation()

std::pair< bool, std::vector< Gcs_packet > > Gcs_message_stage_lz4::apply_transformation ( Gcs_packet &&  packet)
overrideprotectedvirtual

Implements the logic of this stage's transformation to the packet, and returns a set of one, or more, transformed packets.

Parameters
[in]packetThe packet upon which the transformation should be applied
Return values
{true,_}If there was an error applying the transformation
{false,P}If the transformation was successful, and produced the set of transformed packets P

Implements Gcs_message_stage.

◆ get_stage_code()

Stage_code Gcs_message_stage_lz4::get_stage_code ( ) const
inlineoverridevirtual

Return the unique stage code.

Returns
the stage code.

Implements Gcs_message_stage.

Reimplemented in Gcs_message_stage_lz4_v2, and Gcs_message_stage_lz4_v3.

◆ get_stage_header()

std::unique_ptr< Gcs_stage_metadata > Gcs_message_stage_lz4::get_stage_header ( )
overridevirtual

Implements Gcs_message_stage.

◆ max_input_compression()

static constexpr unsigned long long Gcs_message_stage_lz4::max_input_compression ( )
inlinestaticconstexprnoexcept

Return the maximum payload size in bytes that can be compressed.

◆ revert_transformation()

std::pair< Gcs_pipeline_incoming_result, Gcs_packet > Gcs_message_stage_lz4::revert_transformation ( Gcs_packet &&  packet)
overrideprotectedvirtual

Implements the logic to revert this stage's transformation to the packet, and returns one, or none, transformed packet.

Parameters
[in]packetThe packet upon which the transformation should be reverted
Return values
{ERROR,_}If there was an error reverting the transformation
{OK_NO_PACKET,NP}If the transformation was reverted, but produced no packet
{OK_PACKET,P}If the transformation was reverted, and produced the packet P

Implements Gcs_message_stage.

◆ set_threshold()

void Gcs_message_stage_lz4::set_threshold ( unsigned long long  threshold)
inline

Sets the threshold in bytes after which compression kicks in.

Parameters
thresholdif the payload exceeds these many bytes, then the message is compressed.

◆ skip_apply()

Gcs_message_stage::stage_status Gcs_message_stage_lz4::skip_apply ( uint64_t const &  original_payload_size) const
overridevirtual

Check if the apply operation which affects outgoing packets should be executed (i.e.

applied), skipped or aborted.

If the outcome is code apply or code skip, the stage will process or skip the message, respectively. However, if the outcome is code abort, the message will be discarded and an error will be reported thus stopping the pipeline execution.

For example, if a packet's length is less than a pre-defined threshold the packet is not compressed.

Parameters
original_payload_sizeThe size of the packet to which the transformation should be applied.
Returns
a status specifying whether the transformation should be executed, skipped or aborted

Implements Gcs_message_stage.

◆ skip_revert()

Gcs_message_stage::stage_status Gcs_message_stage_lz4::skip_revert ( const Gcs_packet packet) const
overrideprotectedvirtual

Check if the revert operation which affects incoming packets should be executed (i.e.

applied), skipped or aborted.

If the outcome is code apply or code skip, the stage will process or skip the message, respectively. However, if the outcome is code abort, the message will be discarded and an error will be reported thus stopping the pipeline execution.

For example, if the packet length is greater than the maximum allowed compressed information an error is returned.

Parameters
packetThe packet upon which the transformation should be applied
Returns
a status specifying whether the transformation should be executed, skipped or aborted

Implements Gcs_message_stage.

Member Data Documentation

◆ DEFAULT_THRESHOLD

constexpr unsigned long long Gcs_message_stage_lz4::DEFAULT_THRESHOLD = 1024
staticconstexpr

The default threshold value in bytes.

◆ m_threshold

unsigned long long Gcs_message_stage_lz4::m_threshold
private

This marks the threshold in bytes above which a message gets compressed.

Messages that are smaller than this threshold are not compressed.


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