simpledb.record
Class RecordPage

java.lang.Object
  extended by simpledb.record.RecordPage

public class RecordPage
extends Object

Manages the placement and access of records in a block.

Author:
Edward Sciore

Field Summary
static int EMPTY
           
static int INUSE
           
 
Constructor Summary
RecordPage(Block blk, TableInfo ti, Transaction tx)
          Creates the record manager for the specified block.
 
Method Summary
 void close()
          Closes the manager, by unpinning the block.
 int currentId()
          Returns the ID of the current record.
 void delete()
          Deletes the current record.
 int getInt(String fldname)
          Returns the integer value stored for the specified field of the current record.
 String getString(String fldname)
          Returns the string value stored for the specified field of the current record.
 boolean insert()
          Inserts a new, blank record somewhere in the page.
 void moveToId(int id)
          Sets the current record to be the record having the specified ID.
 boolean next()
          Moves to the next record in the block.
 void setInt(String fldname, int val)
          Stores an integer at the specified field of the current record.
 void setString(String fldname, String val)
          Stores a string at the specified field of the current record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final int EMPTY
See Also:
Constant Field Values

INUSE

public static final int INUSE
See Also:
Constant Field Values
Constructor Detail

RecordPage

public RecordPage(Block blk,
                  TableInfo ti,
                  Transaction tx)
Creates the record manager for the specified block. The current record is set to be prior to the first one.

Parameters:
blk - a reference to the disk block
ti - the table's metadata
tx - the transaction performing the operations
Method Detail

close

public void close()
Closes the manager, by unpinning the block.


next

public boolean next()
Moves to the next record in the block.

Returns:
false if there is no next record.

getInt

public int getInt(String fldname)
Returns the integer value stored for the specified field of the current record.

Parameters:
fldname - the name of the field.
Returns:
the integer stored in that field

getString

public String getString(String fldname)
Returns the string value stored for the specified field of the current record.

Parameters:
fldname - the name of the field.
Returns:
the string stored in that field

setInt

public void setInt(String fldname,
                   int val)
Stores an integer at the specified field of the current record.

Parameters:
fldname - the name of the field
val - the integer value stored in that field

setString

public void setString(String fldname,
                      String val)
Stores a string at the specified field of the current record.

Parameters:
fldname - the name of the field
val - the string value stored in that field

delete

public void delete()
Deletes the current record. Deletion is performed by just marking the record as "deleted"; the current record does not change. To get to the next record, call next().


insert

public boolean insert()
Inserts a new, blank record somewhere in the page. Return false if there were no available slots.

Returns:
false if the insertion was not possible

moveToId

public void moveToId(int id)
Sets the current record to be the record having the specified ID.

Parameters:
id - the ID of the record within the page.

currentId

public int currentId()
Returns the ID of the current record.

Returns:
the ID of the current record


Copyright © 2011. All Rights Reserved.