Zero  0.1.0
Public Member Functions | Private Attributes | List of all members
LogScanner Class Reference

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_logrecignore
 

Detailed Description

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.

Author
Caetano Sauer

Constructor & Destructor Documentation

§ LogScanner()

LogScanner::LogScanner ( size_t  blockSize)
inline

§ ~LogScanner()

LogScanner::~LogScanner ( )
inline

Member Function Documentation

§ getBlockSize()

size_t LogScanner::getBlockSize ( )
inline

§ hasPartialLogrec()

bool LogScanner::hasPartialLogrec ( )

§ ignoreAll()

void LogScanner::ignoreAll ( )
inline

§ isIgnored()

bool LogScanner::isIgnored ( logrec_t::kind_t  type)
inline

§ nextLogrec()

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.

§ reset()

void LogScanner::reset ( )

§ setIgnore()

void LogScanner::setIgnore ( logrec_t::kind_t  type)
inline

§ unsetIgnore()

void LogScanner::unsetIgnore ( logrec_t::kind_t  type)
inline

Member Data Documentation

§ blockSize

const size_t LogScanner::blockSize
private

§ ignore

bitset<logrec_t::t_max_logrec> LogScanner::ignore
private

§ toSkip

size_t LogScanner::toSkip
private

§ truncBuf

char* LogScanner::truncBuf
private

§ truncCopied

size_t LogScanner::truncCopied
private

§ truncMissing

size_t LogScanner::truncMissing
private

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