simpledb.tx.recovery
Class SetStringRecord

java.lang.Object
  extended by simpledb.tx.recovery.SetStringRecord
All Implemented Interfaces:
LogRecord

 class SetStringRecord
extends java.lang.Object
implements LogRecord


Field Summary
 
Fields inherited from interface simpledb.tx.recovery.LogRecord
CHECKPOINT, COMMIT, logMgr, ROLLBACK, SETINT, SETSTRING, START
 
Constructor Summary
SetStringRecord(BasicLogRecord rec)
          Creates a log record by reading five other values from the log.
SetStringRecord(int txnum, Block blk, int offset, java.lang.String val)
          Creates a new setstring log record.
 
Method Summary
 int op()
          Returns the log record's type.
 java.lang.String toString()
           
 int txNumber()
          Returns the transaction id stored with the log record.
 void undo(int txnum)
          Replaces the specified data value with the value saved in the log record.
 int writeToLog()
          Writes a setString record to the log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SetStringRecord

public SetStringRecord(int txnum,
                       Block blk,
                       int offset,
                       java.lang.String val)
Creates a new setstring log record.

Parameters:
txnum - the ID of the specified transaction
blk - the block containing the value
offset - the offset of the value in the block
val - the new value

SetStringRecord

public SetStringRecord(BasicLogRecord rec)
Creates a log record by reading five other values from the log.

Parameters:
rec - the basic log record
Method Detail

writeToLog

public int writeToLog()
Writes a setString record to the log. This log record contains the SETSTRING operator, followed by the transaction id, the filename, number, and offset of the modified block, and the previous string value at that offset.

Specified by:
writeToLog in interface LogRecord
Returns:
the LSN of the last log value

op

public int op()
Description copied from interface: LogRecord
Returns the log record's type.

Specified by:
op in interface LogRecord
Returns:
the log record's type

txNumber

public int txNumber()
Description copied from interface: LogRecord
Returns the transaction id stored with the log record.

Specified by:
txNumber in interface LogRecord
Returns:
the log record's transaction id

toString

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

undo

public void undo(int txnum)
Replaces the specified data value with the value saved in the log record. The method pins a buffer to the specified block, calls setString to restore the saved value (using a dummy LSN), and unpins the buffer.

Specified by:
undo in interface LogRecord
Parameters:
txnum - the id of the transaction that is performing the undo.
See Also:
LogRecord.undo(int)