Class LogSequenceNumber

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<LogSequenceNumber>

    public class LogSequenceNumber
    extends java.lang.Object
    implements java.lang.Comparable<LogSequenceNumber>, java.lang.Cloneable
    This class represents a Log Sequence Number (LSN) in the write-ahead log. Every log record has a unique LSN value; furthermore, the LSN identifies the exact location of the log record on disk as well. Log Sequence Numbers are comprised of the following parts:
    • The file number of the write-ahead log file for the record (range: 00000..65535)
    • The offset of the log record from the start of the file (range: 0..231-1)
    This class is immutable so that it can be used in multithreaded code more easily.
    • Field Detail

      • logFileNo

        private int logFileNo
        The number of the write-ahead log file that the record is stored in.
      • fileOffset

        private int fileOffset
        The offset of the log record from the start of the file.
      • recordSize

        private int recordSize
        The size of the record that this LSN points to, in bytes.
    • Constructor Detail

      • LogSequenceNumber

        public LogSequenceNumber​(int logFileNo,
                                 int fileOffset,
                                 int recordSize)
      • LogSequenceNumber

        public LogSequenceNumber​(int logFileNo,
                                 int fileOffset)
      • LogSequenceNumber

        public LogSequenceNumber​(LogSequenceNumber lsn,
                                 int recordSize)
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Calculate a hash-code for this log-sequence number object.
        Overrides:
        hashCode in class java.lang.Object
      • clone

        public LogSequenceNumber clone()
        Overrides:
        clone in class java.lang.Object
      • getLogFileNo

        public int getLogFileNo()
        Returns the file number of the WAL file that this record is in.
        Returns:
        the file number of the WAL file that this record is in.
      • getFileOffset

        public int getFileOffset()
        Returns the offset from the start of the WAL file that this record appears at.
        Returns:
        the offset from the start of the WAL file that this record appears at.
      • getRecordSize

        public int getRecordSize()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object