MySQL 8.0.40
Source Code Documentation
binlog::Decompressing_event_object_istream Class Reference

Stream class that yields Log_event objects from a source. More...

#include <decompressing_event_object_istream.h>

Public Types

using Buffer_stream_t = binary_log::transaction::compression::Payload_event_buffer_istream
 
using Buffer_view_t = Buffer_stream_t::Buffer_view_t
 
using Buffer_ptr_t = Buffer_stream_t::Buffer_ptr_t
 
using Event_ptr_t = std::shared_ptr< Log_event >
 
using Tple_ptr_t = std::shared_ptr< const Transaction_payload_log_event >
 
using Fde_ref_t = const Format_description_event &
 
using Status_t = binary_log::transaction::compression::Decompress_status
 
using Grow_calculator_t = Buffer_stream_t::Grow_calculator_t
 

Public Member Functions

 Decompressing_event_object_istream (IBasic_binlog_file_reader &reader)
 Construct stream over a file, decompressing payload events. More...
 
 Decompressing_event_object_istream (const Tple_ptr_t &transaction_payload_log_event, Fde_ref_t format_description_event)
 Construct stream over a Transaction_payload_log_event. More...
 
 Decompressing_event_object_istream (const Transaction_payload_log_event &transaction_payload_log_event, Fde_ref_t format_description_event)
 Construct stream over a Transaction_payload_log_event. More...
 
 ~Decompressing_event_object_istream ()
 
 Decompressing_event_object_istream (Decompressing_event_object_istream &)=delete
 
 Decompressing_event_object_istream (Decompressing_event_object_istream &&)=delete
 
Decompressing_event_object_istreamoperator= (Decompressing_event_object_istream &)=delete
 
Decompressing_event_object_istreamoperator= (Decompressing_event_object_istream &&)=delete
 
void set_verify_checksum (bool verify_checksum=true)
 Specify whether checksums shall be verified or not. More...
 
Decompressing_event_object_istreamoperator>> (Event_ptr_t &out)
 Read an event from the stream. More...
 
 operator bool () const
 Indicate if EOF or error has not happened. More...
 
bool operator! () const
 Indicate if EOF or error has happened. More...
 
bool has_error () const
 Return true if an error has happened. More...
 
std::string get_error_str () const
 Return a message describing the last error. More...
 
Status_t get_status () const
 Return the status. More...
 
const Grow_calculator_tget_grow_calculator () const
 Return const reference to Grow_calculator to the internal event buffer. More...
 
void set_grow_calculator (const Grow_calculator_t &grow_calculator)
 Set the Grow_calculator for the internal event buffer. More...
 

Private Types

enum class  Read_status { success , eof , error }
 Status from read_from_payload_stream. More...
 

Private Member Functions

raii::Targeted_stringstream error_stream (Status_t status)
 Report an error. More...
 
void begin_payload_event (const Transaction_payload_log_event &tple)
 Prepare to unfold a given Transaction_payload_log_event by setting state variables and creating the Payload_event_buffer_istream object. More...
 
void begin_payload_event (const Tple_ptr_t &tple)
 Prepare to unfold a given Transaction_payload_log_event by setting state variables and creating the Payload_event_buffer_istream object. More...
 
template<class Event_ref_or_ptr >
void do_begin_payload_event (const Transaction_payload_log_event &tple, const Event_ref_or_ptr &ownership_tple)
 Worker function implementing both forms of begin_payload_event. More...
 
bool decode_from_buffer (Buffer_view_t &buffer, Event_ptr_t &out)
 Worker that deserializes an event from the buffer. More...
 
Read_status read_from_payload_stream (Event_ptr_t &out)
 Read and decode next event from the Payload_log_event stream. More...
 
bool read_from_binlog_stream (Event_ptr_t &out)
 Read and decode the next event from the binlog stream. More...
 

Private Attributes

IBasic_binlog_file_readerm_binlog_reader {nullptr}
 Stream of events to read from. More...
 
bool m_verify_checksum {false}
 Whether we should verify checksum. Unused! More...
 
std::string m_error_str
 Error from last operation. More...
 
bool m_end {false}
 True if we have reached EOF, false otherwise. More...
 
Status_t m_status {Status_t::success}
 Status. More...
 
my_off_t m_event_position {0}
 Position of last event. More...
 
bool m_outstanding_error {false}
 True if a read has failed but neither get_error_str nor has_error has been called. More...
 
Grow_calculator_t m_grow_calculator
 Policy for growing buffers in the decompressing stream. More...
 
std::unique_ptr< Buffer_stream_tm_buffer_istream {nullptr}
 The decompression stream; non-null while we are positioned in a TPLE. More...
 
my_off_t m_transaction_payload_event_offset {0}
 end_log_pos for the currently processed TPLE, if any More...
 
int m_embedded_event_number {0}
 0 when not processing a TPLE; N>0 when positioned before the Nth embedded event of a TPLE. More...
 
std::function< Fde_ref_t()> m_get_format_description_event
 Return the current FDE. More...
 

Detailed Description

Stream class that yields Log_event objects from a source.

The source can be a Transaction_payload_log_event, in which case it will produce the contained events. Or it can be a file, in which case it will yield all events in the file, and if there is a Transaction_payload_log_event, it will yield first that and then all the contained events.

The recommended use pattern is:

while (stream >> event) {
// handle event
}
if (stream.has_error()) {
// handle error
}
required string event
Definition: replication_group_member_actions.proto:32

This class actually enforces that you call has_error after the loop; failure to do so will result in an assertion in debug mode. In the unlikely case that your code doesn't need to check for errors, you can get rid of the assert by calling has_error() and discarding the return value.

Member Typedef Documentation

◆ Buffer_ptr_t

◆ Buffer_stream_t

◆ Buffer_view_t

◆ Event_ptr_t

◆ Fde_ref_t

◆ Grow_calculator_t

◆ Status_t

◆ Tple_ptr_t

Member Enumeration Documentation

◆ Read_status

Status from read_from_payload_stream.

Enumerator
success 
eof 
error 

Constructor & Destructor Documentation

◆ Decompressing_event_object_istream() [1/5]

binlog::Decompressing_event_object_istream::Decompressing_event_object_istream ( IBasic_binlog_file_reader reader)
explicit

Construct stream over a file, decompressing payload events.

This will produce all events in the file, and in addition, each Transaction_payload_log_event is followed by the contained events.

Parameters
readerThe source file to read from.

◆ Decompressing_event_object_istream() [2/5]

binlog::Decompressing_event_object_istream::Decompressing_event_object_istream ( const Tple_ptr_t transaction_payload_log_event,
Fde_ref_t  format_description_event 
)

Construct stream over a Transaction_payload_log_event.

This will produce all events contained in the event, but not the event itself.

This Decompressing_event_object_istream will, during its entire life time, hold shared ownership of the Transaction_payload_log_event.

Parameters
transaction_payload_log_eventThe source file to read from.
format_description_eventThe FD event used to parse events.

◆ Decompressing_event_object_istream() [3/5]

binlog::Decompressing_event_object_istream::Decompressing_event_object_istream ( const Transaction_payload_log_event transaction_payload_log_event,
Fde_ref_t  format_description_event 
)

Construct stream over a Transaction_payload_log_event.

This will produce all events contained in the event, but not the event itself.

This Decompressing_event_object_istream will, during its entire life time, hold a pointer to the Transaction_payload_log_event, and the caller must ensure that the event outlives the stream.

Parameters
transaction_payload_log_eventThe source file to read from.
format_description_eventThe FD event used to parse events.

◆ ~Decompressing_event_object_istream()

binlog::Decompressing_event_object_istream::~Decompressing_event_object_istream ( )

◆ Decompressing_event_object_istream() [4/5]

binlog::Decompressing_event_object_istream::Decompressing_event_object_istream ( Decompressing_event_object_istream )
delete

◆ Decompressing_event_object_istream() [5/5]

binlog::Decompressing_event_object_istream::Decompressing_event_object_istream ( Decompressing_event_object_istream &&  )
delete

Member Function Documentation

◆ begin_payload_event() [1/2]

void binlog::Decompressing_event_object_istream::begin_payload_event ( const Tple_ptr_t tple)
inlineprivate

Prepare to unfold a given Transaction_payload_log_event by setting state variables and creating the Payload_event_buffer_istream object.

This object will hold shared ownership of the event.

Parameters
tpleEvent to unfold

◆ begin_payload_event() [2/2]

void binlog::Decompressing_event_object_istream::begin_payload_event ( const Transaction_payload_log_event tple)
inlineprivate

Prepare to unfold a given Transaction_payload_log_event by setting state variables and creating the Payload_event_buffer_istream object.

This object will not hold ownership of the event. The caller must ensure that the event outlives the stream.

Parameters
tpleEvent to unfold

◆ decode_from_buffer()

bool binlog::Decompressing_event_object_istream::decode_from_buffer ( Buffer_view_t buffer,
Event_ptr_t out 
)
private

Worker that deserializes an event from the buffer.

Parameters
[in]bufferInput byte buffer.
[out]outPointer to output event.
Return values
falsesuccess
trueerror

◆ do_begin_payload_event()

template<class Event_ref_or_ptr >
void binlog::Decompressing_event_object_istream::do_begin_payload_event ( const Transaction_payload_log_event tple,
const Event_ref_or_ptr &  ownership_tple 
)
inlineprivate

Worker function implementing both forms of begin_payload_event.

Template Parameters
Event_ref_or_ptrEither reference-to-event or shared-pointer-to-event.
Parameters
tpleEvent to unfold.
ownership_tpleOwnership handle for the event. This can be a shared_ptr if this object should hold shared ownership, or a reference otherwise.

◆ error_stream()

raii::Targeted_stringstream binlog::Decompressing_event_object_istream::error_stream ( Status_t  status)
private

Report an error.

This sets the status as specified, and returns a stringstream to which the caller shall write a message.

Parameters
statusThe status
Returns
Targeted_stringstream object; the error for this stream will be set to the given status.

◆ get_error_str()

std::string binlog::Decompressing_event_object_istream::get_error_str ( ) const

Return a message describing the last error.

Return values
""No error
stringError

◆ get_grow_calculator()

const Decompressing_event_object_istream::Grow_calculator_t & binlog::Decompressing_event_object_istream::get_grow_calculator ( ) const

Return const reference to Grow_calculator to the internal event buffer.

◆ get_status()

Decompressing_event_object_istream::Status_t binlog::Decompressing_event_object_istream::get_status ( ) const

Return the status.

◆ has_error()

bool binlog::Decompressing_event_object_istream::has_error ( ) const

Return true if an error has happened.

◆ operator bool()

binlog::Decompressing_event_object_istream::operator bool ( ) const
explicit

Indicate if EOF or error has not happened.

Return values
truelast read was successful (or there was no last read).
falselast read resulted in end-of-stream or error.

◆ operator!()

bool binlog::Decompressing_event_object_istream::operator! ( ) const

Indicate if EOF or error has happened.

This is the negation of operator bool.

Return values
falselast read was successful, or there was no last read.
truelast read resulted in end-of-stream or error.

◆ operator=() [1/2]

Decompressing_event_object_istream & binlog::Decompressing_event_object_istream::operator= ( Decompressing_event_object_istream &&  )
delete

◆ operator=() [2/2]

Decompressing_event_object_istream & binlog::Decompressing_event_object_istream::operator= ( Decompressing_event_object_istream )
delete

◆ operator>>()

Decompressing_event_object_istream & binlog::Decompressing_event_object_istream::operator>> ( Event_ptr_t out)

Read an event from the stream.

Parameters
outShared pointer to the produced event. If this is a Transaction_payload_log_event, the stream will keep a shared pointer to it, until it has produced all the contained events.
Returns
This object.

◆ read_from_binlog_stream()

bool binlog::Decompressing_event_object_istream::read_from_binlog_stream ( Event_ptr_t out)
private

Read and decode the next event from the binlog stream.

Parameters
[out]outPointer to the output event.
Return values
falseThe event was successfully read and decoded.
trueError or EOF occurred. In case of error, get_error_str will contain the reason.

◆ read_from_payload_stream()

Decompressing_event_object_istream::Read_status binlog::Decompressing_event_object_istream::read_from_payload_stream ( Event_ptr_t out)
private

Read and decode next event from the Payload_log_event stream.

Parameters
[out]outPointer to output event.
Return values
successThe event was successfully read and decoded
errorAn error occurred. get_error_str will contain the reason.
eofNothing was read because the read position was at the end of the event.

◆ set_grow_calculator()

void binlog::Decompressing_event_object_istream::set_grow_calculator ( const Grow_calculator_t grow_calculator)

Set the Grow_calculator for the internal event buffer.

◆ set_verify_checksum()

void binlog::Decompressing_event_object_istream::set_verify_checksum ( bool  verify_checksum = true)

Specify whether checksums shall be verified or not.

Parameters
verify_checksumIf true, verify checksums; otherwise don't.

Member Data Documentation

◆ m_binlog_reader

IBasic_binlog_file_reader* binlog::Decompressing_event_object_istream::m_binlog_reader {nullptr}
private

Stream of events to read from.

◆ m_buffer_istream

std::unique_ptr<Buffer_stream_t> binlog::Decompressing_event_object_istream::m_buffer_istream {nullptr}
private

The decompression stream; non-null while we are positioned in a TPLE.

◆ m_embedded_event_number

int binlog::Decompressing_event_object_istream::m_embedded_event_number {0}
private

0 when not processing a TPLE; N>0 when positioned before the Nth embedded event of a TPLE.

◆ m_end

bool binlog::Decompressing_event_object_istream::m_end {false}
private

True if we have reached EOF, false otherwise.

◆ m_error_str

std::string binlog::Decompressing_event_object_istream::m_error_str
private

Error from last operation.

◆ m_event_position

my_off_t binlog::Decompressing_event_object_istream::m_event_position {0}
private

Position of last event.

◆ m_get_format_description_event

std::function<Fde_ref_t()> binlog::Decompressing_event_object_istream::m_get_format_description_event
private

Return the current FDE.

◆ m_grow_calculator

Grow_calculator_t binlog::Decompressing_event_object_istream::m_grow_calculator
private

Policy for growing buffers in the decompressing stream.

◆ m_outstanding_error

bool binlog::Decompressing_event_object_istream::m_outstanding_error {false}
mutableprivate

True if a read has failed but neither get_error_str nor has_error has been called.

◆ m_status

Status_t binlog::Decompressing_event_object_istream::m_status {Status_t::success}
private

Status.

◆ m_transaction_payload_event_offset

my_off_t binlog::Decompressing_event_object_istream::m_transaction_payload_event_offset {0}
private

end_log_pos for the currently processed TPLE, if any

◆ m_verify_checksum

bool binlog::Decompressing_event_object_istream::m_verify_checksum {false}
private

Whether we should verify checksum. Unused!


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