simpledb.record
Class RecordFile

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

public class RecordFile
extends Object

Manages a file of records. There are methods for iterating through the records and accessing their contents.

Author:
Edward Sciore

Constructor Summary
RecordFile(TableInfo ti, Transaction tx)
          Constructs an object to manage a file of records.
 
Method Summary
 void beforeFirst()
          Positions the current record so that a call to method next will wind up at the first record.
 void close()
          Closes the record file.
 RID currentRid()
          Returns the RID of the current record.
 void delete()
          Deletes the current record.
 int getInt(String fldname)
          Returns the value of the specified field in the current record.
 String getString(String fldname)
          Returns the value of the specified field in the current record.
 void insert()
          Inserts a new, blank record somewhere in the file beginning at the current record.
 void moveToRid(RID rid)
          Positions the current record as indicated by the specified RID.
 boolean next()
          Moves to the next record.
 void setInt(String fldname, int val)
          Sets the value of the specified field in the current record.
 void setString(String fldname, String val)
          Sets the value of the specified field in the current record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordFile

public RecordFile(TableInfo ti,
                  Transaction tx)
Constructs an object to manage a file of records. If the file does not exist, it is created.

Parameters:
ti - the table metadata
tx - the transaction
Method Detail

close

public void close()
Closes the record file.


beforeFirst

public void beforeFirst()
Positions the current record so that a call to method next will wind up at the first record.


next

public boolean next()
Moves to the next record. Returns false if there is no next record.

Returns:
false if there is no next record.

getInt

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

Parameters:
fldname - the name of the field
Returns:
the integer value at that field

getString

public String getString(String fldname)
Returns the value of the specified field in the current record.

Parameters:
fldname - the name of the field
Returns:
the string value at that field

setInt

public void setInt(String fldname,
                   int val)
Sets the value of the specified field in the current record.

Parameters:
fldname - the name of the field
val - the new value for the field

setString

public void setString(String fldname,
                      String val)
Sets the value of the specified field in the current record.

Parameters:
fldname - the name of the field
val - the new value for the field

delete

public void delete()
Deletes the current record. The client must call next() to move to the next record. Calls to methods on a deleted record have unspecified behavior.


insert

public void insert()
Inserts a new, blank record somewhere in the file beginning at the current record. If the new record does not fit into an existing block, then a new block is appended to the file.


moveToRid

public void moveToRid(RID rid)
Positions the current record as indicated by the specified RID.

Parameters:
rid - a record identifier

currentRid

public RID currentRid()
Returns the RID of the current record.

Returns:
a record identifier


Copyright © 2011. All Rights Reserved.