public LogSeqNum append ( Constant [ ] rec ) { logMgrLock . lock ( ) ; try { // two integers that point to the previous and next log records int recsize = pointerSize * 2 ; for ( Constant c : rec ) recsize += Page . size ( ) ; // if the log record doesn't fit, move to the next block if ( currentPos + recsize >= BLOCK_SIZE ) { flush ( ) ; appendNewBlock ( ) ; } // Get the current LSN LogSeqNum lsn = currentLSN ( ) ; // Append a record for ( Constant c : rec ) appendVal ( ) ; finalizeRecord ( ) ; // Remember this LSN lastLsn = lsn ; return lsn ; } finally { logMgrLock . unlock ( ) ; } }
Appends a log record to the file . The record contains an arbitrary array of values . The method also writes an integer to the end of each log record whose value is the offset of the corresponding integer for the previous log record . These integers allow log records to be read in reverse order .