![]() |
MySQL 26.7.0
Source Code Documentation
|
Implementation of the Basic_istream, which reads data from the prefetched relay log. More...
#include <istream_prefetched.h>
Public Member Functions | |
| Istream_prefetched (Log_prefetcher_sptr prefetcher, const std::string &file_name) | |
| Construct from prefetcher. More... | |
| ssize_t | read (unsigned char *buffer, std::size_t length) override |
| Read requested number of bytes from the input stream. More... | |
| bool | seek (my_off_t offset) override |
| If possible, seeks to a given file offset. More... | |
| my_off_t | length () override |
| Returns currently opened file length... More... | |
| virtual | ~Istream_prefetched () override=default |
Public Member Functions inherited from Basic_seekable_istream | |
| virtual | ~Basic_seekable_istream () override=default |
Public Member Functions inherited from Basic_istream | |
| virtual ssize_t | read (unsigned char *buffer, size_t length)=0 |
| Read some bytes from the input stream. More... | |
| virtual | ~Basic_istream ()=default |
Private Types | |
| using | Batch_type = Log_prefetcher::Elem_type |
Private Member Functions | |
| void | copy_to (unsigned char *buffer, std::size_t &buffer_offset, std::size_t bytes) |
| Helper function that copies the requested number of bytes from the current batch into buffer, using the current buffer offset. More... | |
| ssize_t | skip (std::size_t length) |
| Skips requested number of bytes. More... | |
| bool | read_next_batch () |
| Reads the next batch. More... | |
Private Attributes | |
| Log_prefetcher_sptr | m_prefetcher |
| Prefetcher that asynchronously fetches chunks of data from the relay log. More... | |
| std::string | m_allowed_file_name {""} |
| Prefetcher works asynchronously on the whole relay log. More... | |
| Batch_type | m_current_batch |
| Batch currently in use. More... | |
| std::size_t | m_current_offset {0} |
| Current batch offset. More... | |
| std::atomic< bool > | m_is_stopped {false} |
| Variable used to stop waiting for data (read may block) More... | |
| bool | m_prefetcher_error {false} |
| True in case there has been prefetcher error which needs to be propagated. More... | |
| std::size_t | m_file_offset {0} |
| Offset from start of the file. More... | |
Implementation of the Basic_istream, which reads data from the prefetched relay log.
Reads cannot go outside a single relay log file boundary (legacy design). Note that prefetcher is able to move across relay log files. Therefore, to read from the next file, it is sufficient to create a new Istream_prefetched object with the same shared prefetcher object. Istream_prefetched allows for:
Basic_seekable_istream, however, it is probably not required (note Stdin_binlog_istream has the 'length' function disabled) Istream_prefetched does not add new errors to error model, however, it needs to propagate prefetcher error. In case of prefetcher error, read, skip and seek functions will return an error value.
|
private |
| mysql::csa::Istream_prefetched::Istream_prefetched | ( | Log_prefetcher_sptr | prefetcher, |
| const std::string & | file_name | ||
| ) |
Construct from prefetcher.
| prefetcher | Prefetcher object used to obtain data |
| file_name | The file we are allowed to read from |
|
overridevirtualdefault |
|
private |
Helper function that copies the requested number of bytes from the current batch into buffer, using the current buffer offset.
Buffer offset is updated after copy
| buffer | Data will be copied into the following address: buffer + buffer_offset |
| buffer_offset | Current buffer offset, which will be advanced after copy |
| bytes | Copies this amount of bytes |
|
overridevirtual |
|
override |
Read requested number of bytes from the input stream.
It will block when reaching the end of the open stream that is not yet prefetched. This function will read beyond the one file boundary if called many times, unless the requested read would be split into several files. In that case, it will return the number of bytes read till reaching the end of the file.
| buffer | Preallocated buffer to >= length or nullptr |
| length | The requested number of bytes to read. |
| length | Bytes read |
| >=0 | Reached the end of the file or was stopped in the process. EOF : Since one operation cannot go beyond file boundary, operation has been stopped |
| -1 | Error, i.e. prefetcher errored out and cannot read more data |
|
private |
Reads the next batch.
| true | Stopped in the process or source filename changed |
| false | Data read successfully without file change |
|
overridevirtual |
If possible, seeks to a given file offset.
| False | Success |
| True | Cannot seek to requested postion or prefetcher has errored out |
Implements Basic_seekable_istream.
|
private |
Skips requested number of bytes.
Applies the same rules as for read fuction
| length | The requested number of bytes have been skipped |
| >=0 | Reached the end of the file or was stopped in the process. EOF : Since one operation cannot go beyond file boundary, operation has been stopped |
| -1 | Error, i.e. prefetcher errored out and cannot read more data |
|
private |
Prefetcher works asynchronously on the whole relay log.
To comply with implemented structure of Binlog readers, we need to restrict fetching the data to the file that was requested to open. After reaching end of this file, instead of fetching next batches we report EOF.
|
private |
Batch currently in use.
|
private |
Current batch offset.
|
private |
Offset from start of the file.
|
private |
Variable used to stop waiting for data (read may block)
|
private |
Prefetcher that asynchronously fetches chunks of data from the relay log.
|
private |
True in case there has been prefetcher error which needs to be propagated.