|
Zero
0.1.0
|
Parses log records from a stream of binary data. More...
#include <log_consumer.h>
Public Member Functions | |
| bool | nextLogrec (char *src, size_t &pos, logrec_t *&lr, lsn_t *nextLSN=nullptr, lsn_t *stopLSN=nullptr, int *lrLength=nullptr) |
| bool | hasPartialLogrec () |
| void | reset () |
| LogScanner (size_t blockSize) | |
| ~LogScanner () | |
| size_t | getBlockSize () |
| void | setIgnore (logrec_t::kind_t type) |
| void | ignoreAll () |
| void | unsetIgnore (logrec_t::kind_t type) |
| bool | isIgnored (logrec_t::kind_t type) |
Private Attributes | |
| size_t | truncCopied |
| size_t | truncMissing |
| size_t | toSkip |
| const size_t | blockSize |
| char * | truncBuf |
| bitset< logrec_t::t_max_logrec > | ignore |
Parses log records from a stream of binary data.
This class is not a scanner per se, as it does not perform any I/O. However, it enables efficient scanning by reading whole blocks of binary data from the recovery log and parsing log records from them using this class. This is an improvement over the traditional "scan" implemented in Shore-MT, which performs one random read for each log record. The major task implemented in this class is the control of block boundaries, which can occur in the middle of a log record (i.e., log records may spawn multiple blocks). To that end, it maintains an internal log record buffer to reconstruct such log records.
Log records are delivered via the nextLogrec() method, which takes the block address and offset within the block as parameters. Once the log record is parsed, the offset is updated (i.e., it is an output parameter). The method returns true if the log record was found entirely in the current block. Otherwise, it saves the partial data into its internal buffer and returns false, indicating to the caller that a new block must be provided. Upon invoking nextLogrec() once again, the caller then receives the complete log record.
|
inline |
|
inline |
|
inline |
| bool LogScanner::hasPartialLogrec | ( | ) |
|
inline |
|
inline |
| bool LogScanner::nextLogrec | ( | char * | src, |
| size_t & | pos, | ||
| logrec_t *& | lr, | ||
| lsn_t * | nextLSN = nullptr, |
||
| lsn_t * | stopLSN = nullptr, |
||
| int * | lrLength = nullptr |
||
| ) |
Fetches a log record from the read buffer ('src' in offset 'pos'). Handles incomplete records due to block boundaries in the buffer and skips checkpoints and skip log records. Returns false if whole record could not be read in the current buffer block, indicating that the caller must fetch a new block into 'src' and invoke method again.
Method loops until any in-block skipping is completed.
| void LogScanner::reset | ( | ) |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
1.8.12