RecordFileHandle Class Reference

Record file handle class. More...

#include <RecordFileHandle.h>

List of all members.

Public Member Functions

 RecordFileHandle ()
 Constructor for RecordFileHandle.
 ~RecordFileHandle ()
 Destructor for RecordFileHandle.
ReturnCode initialize (PageFileHandle *fileHandle)
 Initializes the RecordFileHandle.
ReturnCode getRecord (RecordID *rid, Record *record)
 Gets a record from the file.
ReturnCode insertRecord (char *data, RecordID *rid)
 Inserts a record into the file.
ReturnCode deleteRecord (RecordID *rid)
 Deletes a record from the file.
ReturnCode updateRecord (Record *record)
 Updates the contents of a record.
ReturnCode forcePage (int pageNo)
 Flushes the specified page to disk.
ReturnCode forceAllPages ()
 Flushes all dirty pages to disk.
PageFileHandlegetFileHandle ()
 Gets the file handle for this record file.
uint getRecordSize ()
 Gets the record size for this record file.


Detailed Description

Record file handle class.

Member Function Documentation

ReturnCode RecordFileHandle::initialize ( PageFileHandle fileHandle  ) 

Initializes the RecordFileHandle.

Parameters:
fileHandle The file handle for the underlying page file
Initializes the RecordFileHandle object. Returns RC_OK on success, or other ReturnCode values on failure. You will probably want to read some header page information in this method's implementation (including, e.g., the record size for this file), and cache this information locally.

Note, since RecordManager is a singleton class, you may simply ignore the recordMgr parameter in your implementation of this method: the record manager for *every* record file handle is the one returned by RecordManager::getInstance.

ReturnCode RecordFileHandle::getRecord ( RecordID rid,
Record record 
)

Gets a record from the file.

Parameters:
rid The identifier of the desired record
record A Record structure to fill with a copy of the record
Reads a record from the file and copies the record into the supplied Record structure. Returns RC_OK on success, RC_RECORD_NOT_FOUND if the specified record is not found, and other ReturnCode values if there is some other error.

ReturnCode RecordFileHandle::insertRecord ( char *  data,
RecordID rid 
)

Inserts a record into the file.

Parameters:
data The data for the record
rid Out parameter where the new record identifier is returned
Inserts a new record into the file. The data parameter is an array of bytes of length defined by the record size for this file. Returns RC_OK on success and copies the identifer for the new record into the supplied RecordID structure. Returns other ReturnCode values on failure.

ReturnCode RecordFileHandle::deleteRecord ( RecordID rid  ) 

Deletes a record from the file.

Parameters:
rid The identifier of the record to delete
Deletes the specified record from the file. Returns RC_OK on success, RC_RECORD_NOT_FOUND if the specified record was not found, and other ReturnCode values in case of any other failure.

ReturnCode RecordFileHandle::updateRecord ( Record record  ) 

Updates the contents of a record.

Parameters:
record The new version of the record
Updates an existing record, identified by the RecordID in the record parameter, with the data of the record parameter. Returns RC_OK on success, RC_RECORD_NOT_FOUND if the specified record is not found, and other ReturnCode values in case of any other failure.

ReturnCode RecordFileHandle::forcePage ( int  pageNo  ) 

Flushes the specified page to disk.

Parameters:
pageNo The number of the page to flush
Flushes the specified page to disk. Returns RC_OK on success, or other ReturnCode values as specified in FileHandle::forcePage otherwise.

ReturnCode RecordFileHandle::forceAllPages (  ) 

Flushes all dirty pages to disk.

Flushes all dirty pages to disk. Returns RC_OK on success, or other ReturnCode values as specified in FileHandle::forceAllPages otherwise.

PageFileHandle * RecordFileHandle::getFileHandle (  ) 

Gets the file handle for this record file.

Gets the file handle for this record file. Intended to be used by other record manager components such as RecordFileScan that may require page-level access.


The documentation for this class was generated from the following files:

Generated on Mon May 16 17:05:06 2011 by  doxygen 1.5.6