MySQL 8.0.39
Source Code Documentation
|
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_istream & | operator= (Decompressing_event_object_istream &)=delete |
Decompressing_event_object_istream & | operator= (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_istream & | operator>> (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_t & | get_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_reader * | m_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_t > | m_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... | |
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:
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.
using binlog::Decompressing_event_object_istream::Buffer_stream_t = binary_log::transaction::compression::Payload_event_buffer_istream |
using binlog::Decompressing_event_object_istream::Event_ptr_t = std::shared_ptr<Log_event> |
using binlog::Decompressing_event_object_istream::Grow_calculator_t = Buffer_stream_t::Grow_calculator_t |
using binlog::Decompressing_event_object_istream::Status_t = binary_log::transaction::compression::Decompress_status |
using binlog::Decompressing_event_object_istream::Tple_ptr_t = std::shared_ptr<const Transaction_payload_log_event> |
|
strongprivate |
|
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.
reader | The source file to read from. |
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.
transaction_payload_log_event | The source file to read from. |
format_description_event | The FD event used to parse events. |
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.
transaction_payload_log_event | The source file to read from. |
format_description_event | The FD event used to parse events. |
binlog::Decompressing_event_object_istream::~Decompressing_event_object_istream | ( | ) |
|
delete |
|
delete |
|
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.
tple | Event to unfold |
|
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.
tple | Event to unfold |
|
private |
Worker that deserializes an event from the buffer.
[in] | buffer | Input byte buffer. |
[out] | out | Pointer to output event. |
false | success |
true | error |
|
inlineprivate |
Worker function implementing both forms of begin_payload_event.
Event_ref_or_ptr | Either reference-to-event or shared-pointer-to-event. |
tple | Event to unfold. |
ownership_tple | Ownership handle for the event. This can be a shared_ptr if this object should hold shared ownership, or a reference otherwise. |
|
private |
Report an error.
This sets the status as specified, and returns a stringstream to which the caller shall write a message.
status | The status |
std::string binlog::Decompressing_event_object_istream::get_error_str | ( | ) | const |
Return a message describing the last error.
"" | No error |
string | Error |
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.
Decompressing_event_object_istream::Status_t binlog::Decompressing_event_object_istream::get_status | ( | ) | const |
Return the status.
bool binlog::Decompressing_event_object_istream::has_error | ( | ) | const |
Return true if an error has happened.
|
explicit |
Indicate if EOF or error has not happened.
true | last read was successful (or there was no last read). |
false | last read resulted in end-of-stream or error. |
bool binlog::Decompressing_event_object_istream::operator! | ( | ) | const |
Indicate if EOF or error has happened.
This is the negation of operator bool
.
false | last read was successful, or there was no last read. |
true | last read resulted in end-of-stream or error. |
|
delete |
|
delete |
Decompressing_event_object_istream & binlog::Decompressing_event_object_istream::operator>> | ( | Event_ptr_t & | out | ) |
Read an event from the stream.
out | Shared 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. |
|
private |
Read and decode the next event from the binlog stream.
[out] | out | Pointer to the output event. |
false | The event was successfully read and decoded. |
true | Error or EOF occurred. In case of error, get_error_str will contain the reason. |
|
private |
Read and decode next event from the Payload_log_event stream.
[out] | out | Pointer to output event. |
success | The event was successfully read and decoded |
error | An error occurred. get_error_str will contain the reason. |
eof | Nothing was read because the read position was at the end of the event. |
void binlog::Decompressing_event_object_istream::set_grow_calculator | ( | const Grow_calculator_t & | grow_calculator | ) |
Set the Grow_calculator for the internal event buffer.
void binlog::Decompressing_event_object_istream::set_verify_checksum | ( | bool | verify_checksum = true | ) |
Specify whether checksums shall be verified or not.
verify_checksum | If true, verify checksums; otherwise don't. |
|
private |
Stream of events to read from.
|
private |
The decompression stream; non-null while we are positioned in a TPLE.
|
private |
0 when not processing a TPLE; N>0 when positioned before the Nth embedded event of a TPLE.
|
private |
True if we have reached EOF, false otherwise.
|
private |
Error from last operation.
|
private |
Position of last event.
|
private |
Return the current FDE.
|
private |
Policy for growing buffers in the decompressing stream.
|
mutableprivate |
True if a read has failed but neither get_error_str
nor has_error
has been called.
|
private |
Status.
|
private |
end_log_pos for the currently processed TPLE, if any
|
private |
Whether we should verify checksum. Unused!