MySQL 26.7.0
Source Code Documentation
mysql::csa::Event_set_fetchable_cache Class Reference

Empty implementation of Event_set_fetchable that does not fetch events from the storage as they were already fetched. More...

#include <event_set_fetchable_cache.h>

Inheritance diagram for mysql::csa::Event_set_fetchable_cache:
[legend]

Public Types

using Log_event_ptr = std::shared_ptr< Log_event >
 Shared pointer to a Log_event. More...
 
using Return_status = mysql::utils::Return_status
 Type alias for return status. More...
 
using Event_set_type = std::vector< IReader_event_ptr >
 Vector of Log_event_ptr representing a set of events. More...
 
using Stream_type = ::binlog::Decompressing_event_object_istream
 Type alias for the decompressing event stream. More...
 
using Stream_ptr = std::unique_ptr< Stream_type >
 Unique pointer to the decompressing stream. More...
 
- Public Types inherited from mysql::csa::Event_set_fetchable
using Fde_type = Format_description_log_event
 
using Fde_ptr = Fde_type *
 
using Log_event_ptr = std::shared_ptr< Log_event >
 

Public Member Functions

 Event_set_fetchable_cache (Event_set_type &&events, bool is_trx, Log_event_ptr fde, Relay_log_deleter_handle delete_file_handle, bool streaming_open=false)
 Constructs an Event_set_fetchable_cache with pre-fetched events. More...
 
bool wait_next () override
 Fetches the next event from the internal cache. More...
 
std::optional< Managed_eventfetch_next () override
 Fetches the next event if possible. More...
 
const std::string & get_error_str () const override
 Retrieves the error message if any error occurred. More...
 
bool is_done () const override
 Checks if the fetchable stream has finished processing without error. More...
 
bool is_error () const override
 Checks if an error occurred in the fetchable stream. More...
 
bool is_trx () const override
 Checks if this event set represents a transaction. More...
 
void reset (bool reset_events) override
 Resets the state to allow fetching the event set again, clearing any error state. More...
 
virtual ~Event_set_fetchable_cache () override
 Destructor. More...
 
Fde_ptr get_fde () override
 Obtains non-owning pointer to current transaction FDE. More...
 
void set_success () override
 Callback notifying that task was executed successfully. More...
 
void append_event (IReader_event_ptr event, bool seal_after=false)
 Appends one event to a stream-open cache batch. More...
 
void seal_stream ()
 Seals stream-open cache batch. More...
 
void set_stream_truncated ()
 Marks stream-open cache batch as truncated. More...
 
- Public Member Functions inherited from mysql::csa::Event_set_fetchable
virtual ~Event_set_fetchable ()=default
 Sets the end of the stream if needed. More...
 

Private Member Functions

std::optional< Log_event_ptrdecompress ()
 Decompresses and returns the next event from the TPLE stream. More...
 
void end_decompression ()
 Helper to deinitialize the decompression stream and update status. More...
 
void start_decompression ()
 Helper to initialize the decompression stream and update status. More...
 

Private Attributes

Event_set_type m_events
 Cached vector of events. More...
 
bool m_is_done = false
 Flag indicating if processing is done (finished or error). More...
 
std::size_t m_event_id {0}
 Index of the next event to fetch. More...
 
std::string m_failure_msg {""}
 Detailed error message if any. More...
 
Return_status m_status
 Status of the object. More...
 
bool m_is_trx {false}
 Flag indicating if this is a transaction. More...
 
bool m_decompressing {false}
 Flag indicating if currently decompressing a TPLE. More...
 
Stream_ptr m_decompressing_stream {}
 Decompressing stream created from TPLE if any. More...
 
Transaction_payload_log_eventm_compressed_event_ptr {nullptr}
 Non-owning pointer to compressed event casted to Transaction_payload_log_event. More...
 
Log_event_ptr m_compressed_event {}
 Compressed event used during decompression. More...
 
Log_event_ptr m_fde_base {}
 Owning pointer to Format_description_event. More...
 
Fde_ptr m_fde {}
 Non-owning pointer to Format_description_event. More...
 
Relay_log_deleter_handle m_delete_file_handle
 Handle to relay log deleter, relay log will be removed when last living reference to this file is released. More...
 
std::mutex m_stream_mutex
 Stream synchronization state. More...
 
std::condition_variable m_stream_cv
 
bool m_stream_open {false}
 
bool m_stream_sealed {true}
 
bool m_stream_truncated {false}
 

Detailed Description

Empty implementation of Event_set_fetchable that does not fetch events from the storage as they were already fetched.

It returns cached event objects instead.

Member Typedef Documentation

◆ Event_set_type

Vector of Log_event_ptr representing a set of events.

◆ Log_event_ptr

Shared pointer to a Log_event.

◆ Return_status

◆ Stream_ptr

Unique pointer to the decompressing stream.

◆ Stream_type

Constructor & Destructor Documentation

◆ Event_set_fetchable_cache()

mysql::csa::Event_set_fetchable_cache::Event_set_fetchable_cache ( Event_set_fetchable_cache::Event_set_type &&  events,
bool  is_trx,
Event_set_fetchable::Log_event_ptr  fde,
Relay_log_deleter_handle  delete_file_handle,
bool  streaming_open = false 
)

Constructs an Event_set_fetchable_cache with pre-fetched events.

Parameters
eventsThe vector of events to cache (moved into the object).
is_trxFlag indicating if this set represents a transaction.
fdeShared pointer to the Format_description_event.
delete_file_handleHandle to the relay log deleter.
streaming_openIf true, events may be appended concurrently.

◆ ~Event_set_fetchable_cache()

mysql::csa::Event_set_fetchable_cache::~Event_set_fetchable_cache ( )
overridevirtual

Destructor.

Member Function Documentation

◆ append_event()

void mysql::csa::Event_set_fetchable_cache::append_event ( IReader_event_ptr  event,
bool  seal_after = false 
)

Appends one event to a stream-open cache batch.

Parameters
eventEvent to append
seal_afterWhen true, the batch is sealed together with publish.

◆ decompress()

std::optional< Event_set_fetchable_cache::Log_event_ptr > mysql::csa::Event_set_fetchable_cache::decompress ( )
private

Decompresses and returns the next event from the TPLE stream.

Returns
Optional Log_event_ptr if successful, empty if failed or stream ended.

◆ end_decompression()

void mysql::csa::Event_set_fetchable_cache::end_decompression ( )
private

Helper to deinitialize the decompression stream and update status.

◆ fetch_next()

std::optional< Managed_event > mysql::csa::Event_set_fetchable_cache::fetch_next ( )
overridevirtual

Fetches the next event if possible.

Callers are expected to wait for availability with wait_next() first when the underlying implementation supports streaming updates.

Returns
Managed_event object or an empty optional if the stream ended (with or without error).

Implements mysql::csa::Event_set_fetchable.

◆ get_error_str()

const std::string & mysql::csa::Event_set_fetchable_cache::get_error_str ( ) const
overridevirtual

Retrieves the error message if any error occurred.

Returns
Const reference to the error message string.

Implements mysql::csa::Event_set_fetchable.

◆ get_fde()

Event_set_fetchable::Fde_ptr mysql::csa::Event_set_fetchable_cache::get_fde ( )
overridevirtual

Obtains non-owning pointer to current transaction FDE.

Returns
Non-owning pointer to FDE

Implements mysql::csa::Event_set_fetchable.

◆ is_done()

bool mysql::csa::Event_set_fetchable_cache::is_done ( ) const
overridevirtual

Checks if the fetchable stream has finished processing without error.

Returns
true if finished without error, false otherwise.

Implements mysql::csa::Event_set_fetchable.

◆ is_error()

bool mysql::csa::Event_set_fetchable_cache::is_error ( ) const
overridevirtual

Checks if an error occurred in the fetchable stream.

Returns
true if an error occurred, false otherwise.

Implements mysql::csa::Event_set_fetchable.

◆ is_trx()

bool mysql::csa::Event_set_fetchable_cache::is_trx ( ) const
overridevirtual

Checks if this event set represents a transaction.

Returns
true if it contains a transaction, false otherwise.

Implements mysql::csa::Event_set_fetchable.

◆ reset()

void mysql::csa::Event_set_fetchable_cache::reset ( bool  reset_events)
overridevirtual

Resets the state to allow fetching the event set again, clearing any error state.

Parameters
reset_eventsWhen true events states need to be reset

Implements mysql::csa::Event_set_fetchable.

◆ seal_stream()

void mysql::csa::Event_set_fetchable_cache::seal_stream ( )

Seals stream-open cache batch.

◆ set_stream_truncated()

void mysql::csa::Event_set_fetchable_cache::set_stream_truncated ( )

Marks stream-open cache batch as truncated.

◆ set_success()

void mysql::csa::Event_set_fetchable_cache::set_success ( )
overridevirtual

Callback notifying that task was executed successfully.

Reimplemented from mysql::csa::Event_set_fetchable.

◆ start_decompression()

void mysql::csa::Event_set_fetchable_cache::start_decompression ( )
private

Helper to initialize the decompression stream and update status.

◆ wait_next()

bool mysql::csa::Event_set_fetchable_cache::wait_next ( )
overridevirtual

Fetches the next event from the internal cache.

Returns
Managed_event or empty optional in case of stream end or error. Error can be checked with 'is_error'. Decompresses events if necessary.

Implements mysql::csa::Event_set_fetchable.

Member Data Documentation

◆ m_compressed_event

Log_event_ptr mysql::csa::Event_set_fetchable_cache::m_compressed_event {}
private

Compressed event used during decompression.

◆ m_compressed_event_ptr

Transaction_payload_log_event* mysql::csa::Event_set_fetchable_cache::m_compressed_event_ptr {nullptr}
private

Non-owning pointer to compressed event casted to Transaction_payload_log_event.

◆ m_decompressing

bool mysql::csa::Event_set_fetchable_cache::m_decompressing {false}
private

Flag indicating if currently decompressing a TPLE.

◆ m_decompressing_stream

Stream_ptr mysql::csa::Event_set_fetchable_cache::m_decompressing_stream {}
private

Decompressing stream created from TPLE if any.

◆ m_delete_file_handle

Relay_log_deleter_handle mysql::csa::Event_set_fetchable_cache::m_delete_file_handle
private

Handle to relay log deleter, relay log will be removed when last living reference to this file is released.

◆ m_event_id

std::size_t mysql::csa::Event_set_fetchable_cache::m_event_id {0}
private

Index of the next event to fetch.

◆ m_events

Event_set_type mysql::csa::Event_set_fetchable_cache::m_events
private

Cached vector of events.

◆ m_failure_msg

std::string mysql::csa::Event_set_fetchable_cache::m_failure_msg {""}
private

Detailed error message if any.

◆ m_fde

Fde_ptr mysql::csa::Event_set_fetchable_cache::m_fde {}
private

Non-owning pointer to Format_description_event.

◆ m_fde_base

Log_event_ptr mysql::csa::Event_set_fetchable_cache::m_fde_base {}
private

Owning pointer to Format_description_event.

◆ m_is_done

bool mysql::csa::Event_set_fetchable_cache::m_is_done = false
private

Flag indicating if processing is done (finished or error).

◆ m_is_trx

bool mysql::csa::Event_set_fetchable_cache::m_is_trx {false}
private

Flag indicating if this is a transaction.

◆ m_status

Return_status mysql::csa::Event_set_fetchable_cache::m_status
private

Status of the object.

◆ m_stream_cv

std::condition_variable mysql::csa::Event_set_fetchable_cache::m_stream_cv
private

◆ m_stream_mutex

std::mutex mysql::csa::Event_set_fetchable_cache::m_stream_mutex
mutableprivate

Stream synchronization state.

◆ m_stream_open

bool mysql::csa::Event_set_fetchable_cache::m_stream_open {false}
private

◆ m_stream_sealed

bool mysql::csa::Event_set_fetchable_cache::m_stream_sealed {true}
private

◆ m_stream_truncated

bool mysql::csa::Event_set_fetchable_cache::m_stream_truncated {false}
private

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