CLASS log
#include <log.h>
log maintains the list of log records in a file as they are generated.
Fields
masterlog mlog
FILE* logfile
- the file (named 'ourlog') that is where the log writes and reads its log records
Methods
bool read ( const lsn_t &lsn, logrecord &logrec )
Reads the log record with log sequence number lsn from the log and stores it in logrec. When reading, be sure to check the return value: if FALSE, read failed and the log record read is incorrect or empty.
lsn_t write(logrecord &logrec);
Writes a log record (logrec) onto the log and returns the log sequence number that was assigned to it. This LSN is also used to mark the position in the logfile that the record was written to. When writing, be sure to check the return value: if FALSE, nothing was written to the log.
bool read_next_logrec ( const lsn_t ¤tlsn, logrecord &logrec )
Reads from the log, the log record following the one with LSN equal to currentlsn and stores it into logrec.
lsn_t get_next_lsn ( )
Retrieves the next available LSN. This is done by locating the next free slot in the log file and returning this offset into the file as the LSN.