Package edu.caltech.nanodb.transactions
Class TransactionStatePage
- java.lang.Object
-
- edu.caltech.nanodb.transactions.TransactionStatePage
-
public class TransactionStatePage extends java.lang.Object
This class wraps the transaction-state page to provide basic operations necessary for reading and storing essential values. The values stored in the transaction-state file are as follows:- Next Transaction ID. This is the next transaction ID, as recorded by the database at the last point this file was saved.
- First Log Sequence Number (LSN). This is the LSN in the write-ahead log (WAL) where recovery should start from. It denotes a point in time where all table files and the WAL are completely in sync with each other. Since NanoDB doesn't support checkpointing (yet), this value is usually updated after recovery is completed, and also upon proper shutdown of the database.
- Next LSN. This value is one byte past the last valid WAL record
that has been successfully written and sync'd to the write-ahead
log. Note that this value may be behind the
WALManager.nextLSN
value stored in memory.
-
-
Field Summary
Fields Modifier and Type Field Description private DBPage
dbPage
static int
OFFSET_FIRST_LSN_FILENUM
The offset in the checkpoint page where the "First Log Sequence Number" file-number is stored.static int
OFFSET_FIRST_LSN_OFFSET
The offset in the checkpoint page where the "First Log Sequence Number" file-offset is stored.static int
OFFSET_NEXT_LSN_FILENUM
The offset in the checkpoint page where the "Next Log Sequence Number" file-number is stored.static int
OFFSET_NEXT_LSN_OFFSET
The offset in the checkpoint page where the "Next Log Sequence Number" file-offset is stored.static int
OFFSET_NEXT_TXN_ID
The offset in the checkpoint page where the "Next Transaction ID" value is stored.
-
Constructor Summary
Constructors Constructor Description TransactionStatePage(DBPage dbPage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogSequenceNumber
getFirstLSN()
LogSequenceNumber
getNextLSN()
int
getNextTransactionID()
void
setFirstLSN(LogSequenceNumber firstLSN)
void
setNextLSN(LogSequenceNumber nextLSN)
void
setNextTransactionID(int nextTransactionID)
-
-
-
Field Detail
-
OFFSET_NEXT_TXN_ID
public static final int OFFSET_NEXT_TXN_ID
The offset in the checkpoint page where the "Next Transaction ID" value is stored. This value is a signed int (4 bytes).- See Also:
- Constant Field Values
-
OFFSET_FIRST_LSN_FILENUM
public static final int OFFSET_FIRST_LSN_FILENUM
The offset in the checkpoint page where the "First Log Sequence Number" file-number is stored. This value is an unsigned short (2 bytes).- See Also:
- Constant Field Values
-
OFFSET_FIRST_LSN_OFFSET
public static final int OFFSET_FIRST_LSN_OFFSET
The offset in the checkpoint page where the "First Log Sequence Number" file-offset is stored. This value is a signed int (4 bytes).- See Also:
- Constant Field Values
-
OFFSET_NEXT_LSN_FILENUM
public static final int OFFSET_NEXT_LSN_FILENUM
The offset in the checkpoint page where the "Next Log Sequence Number" file-number is stored. This value is an unsigned short (2 bytes).- See Also:
- Constant Field Values
-
OFFSET_NEXT_LSN_OFFSET
public static final int OFFSET_NEXT_LSN_OFFSET
The offset in the checkpoint page where the "Next Log Sequence Number" file-offset is stored. This value is a signed int (4 bytes).- See Also:
- Constant Field Values
-
dbPage
private DBPage dbPage
-
-
Constructor Detail
-
TransactionStatePage
public TransactionStatePage(DBPage dbPage)
-
-
Method Detail
-
getNextTransactionID
public int getNextTransactionID()
-
setNextTransactionID
public void setNextTransactionID(int nextTransactionID)
-
getFirstLSN
public LogSequenceNumber getFirstLSN()
-
setFirstLSN
public void setFirstLSN(LogSequenceNumber firstLSN)
-
getNextLSN
public LogSequenceNumber getNextLSN()
-
setNextLSN
public void setNextLSN(LogSequenceNumber nextLSN)
-
-