Class LogSequenceNumber
- java.lang.Object
-
- edu.caltech.nanodb.storage.writeahead.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)
-
-
Field Summary
Fields Modifier and Type Field Description private int
fileOffset
The offset of the log record from the start of the file.private int
logFileNo
The number of the write-ahead log file that the record is stored in.private int
recordSize
The size of the record that this LSN points to, in bytes.
-
Constructor Summary
Constructors Constructor Description LogSequenceNumber(int logFileNo, int fileOffset)
LogSequenceNumber(int logFileNo, int fileOffset, int recordSize)
LogSequenceNumber(LogSequenceNumber lsn, int recordSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogSequenceNumber
clone()
int
compareTo(LogSequenceNumber lsn)
boolean
equals(java.lang.Object obj)
int
getFileOffset()
Returns the offset from the start of the WAL file that this record appears at.int
getLogFileNo()
Returns the file number of the WAL file that this record is in.int
getRecordSize()
int
hashCode()
Calculate a hash-code for this log-sequence number object.java.lang.String
toString()
-
-
-
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 classjava.lang.Object
-
hashCode
public int hashCode()
Calculate a hash-code for this log-sequence number object.- Overrides:
hashCode
in classjava.lang.Object
-
clone
public LogSequenceNumber clone()
- Overrides:
clone
in classjava.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()
-
compareTo
public int compareTo(LogSequenceNumber lsn)
- Specified by:
compareTo
in interfacejava.lang.Comparable<LogSequenceNumber>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-