SwatDB
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends | List of all members
RelationFile Class Referenceabstract

#include <relationfile.h>

Inheritance diagram for RelationFile:
Inheritance graph
[legend]
Collaboration diagram for RelationFile:
Collaboration graph
[legend]

Public Member Functions

 RelationFile (Catalog *catalog, BufferManager *buf_mgr, Schema *schema)
 Constructor. Initializes common state associated with every file, including catalog, buf_mgr, and schema.
 
virtual ~RelationFile ()
 Destructor. Data members are cleaned up, but none of the dynamically allocated data members are deleted. The underlying Unix file is not deleted.
 
virtual std::uint32_t getNumPages ()
 virtual function that returns the number of pages in the file
 
virtual std::uint64_t getNumRecords ()
 virtual function that returns the number of records in the file
 
SchemagetSchema ()
 Returns the schema of the File.
 
virtual RecordId insertRecord (Record record)=0
 Virtual method for inserting a Record into the RelationFile.
 
virtual void getRecord (RecordId record_id, Record *record)=0
 Virtual method for getting record of the given RecordId.
 
virtual void updateRecord (RecordId record_id, Record record)=0
 Virtual method for updating record of the given RecordId.
 
virtual void deleteRecord (RecordId record_id)=0
 Virtual method for deleting record of the given RecordId.
 
- Public Member Functions inherited from File
 File (Catalog *catalog, BufferManager *buf_mgr)
 Constructor. Initializes common state associated with every file, including catalog, buf_mgr, and schema.
 
virtual ~File ()
 Destructor. Data members are cleaned up, but none of the dynamically allocated data members are deleted. The underlying Unix file is not deleted.
 
virtual void createHeader ()=0
 Allocates and initializes the header. Is a virtual method to be overridden at each derived class.
 
virtual void flushHeader ()=0
 Flushes Header Page to disk. Is a virtual method to be overridden at each derived class.
 
FileId getFileId ()
 Returns the FileId of the File.
 
virtual void printFile ()
 Prints out information and/or the contents of the file. Can be overwritten in derived classes. Useful for debugging and testing purposes.
 
PageId getHeaderId ()
 Returns Header PageId.
 

Protected Attributes

Schemaschema
 
- Protected Attributes inherited from File
FileId file_id
 
Catalogcatalog
 
BufferManagerbuf_mgr
 
PageId header_id
 

Friends

class Catalog
 
class FileManager
 

Additional Inherited Members

- Protected Member Functions inherited from File
void _setFileId (FileId file_id)
 Sets the file_id and the schema fields of this File.
 

Detailed Description

SwatDB RelationFile Class. Represents relation file in the system. It is an abstract class from which lower level relation file implementations (heapfile) inherit. Abstract methods for inserting, updating, and deleting records are defined. There may be other lower level methods that are implementation specific (and hence not defined here).

Constructor & Destructor Documentation

◆ RelationFile()

RelationFile::RelationFile ( Catalog catalog,
BufferManager buf_mgr,
Schema schema 
)

Constructor. Initializes common state associated with every file, including catalog, buf_mgr, and schema.

Parameters
catalogPointer to the SwatDB Catalog. Needed for getting file and idex relation files and schema.
buf_mgrPointer to the SwatDB Buffer Manager. Needed for de/allocating Pages, for getting and flushing Pages.
schema.Pointer to Schema for the File.
Precondition
Input paramaters (pointers) are all valid.
Postcondition
The data members of File are initialized. file_id and header_id, however, are not set.

Member Function Documentation

◆ deleteRecord()

virtual void RelationFile::deleteRecord ( RecordId  record_id)
pure virtual

Virtual method for deleting record of the given RecordId.

Implemented in HeapFile.

◆ getNumPages()

virtual std::uint32_t RelationFile::getNumPages ( )
inlinevirtual

virtual function that returns the number of pages in the file

Reimplemented in HeapFile.

◆ getNumRecords()

virtual std::uint64_t RelationFile::getNumRecords ( )
inlinevirtual

virtual function that returns the number of records in the file

Reimplemented in HeapFile.

◆ getRecord()

virtual void RelationFile::getRecord ( RecordId  record_id,
Record record 
)
pure virtual

Virtual method for getting record of the given RecordId.

Implemented in HeapFile.

◆ getSchema()

Schema * RelationFile::getSchema ( )

Returns the schema of the File.

Returns
schema of the File.

◆ insertRecord()

virtual RecordId RelationFile::insertRecord ( Record  record)
pure virtual

Virtual method for inserting a Record into the RelationFile.

Implemented in HeapFile.

◆ updateRecord()

virtual void RelationFile::updateRecord ( RecordId  record_id,
Record  record 
)
pure virtual

Virtual method for updating record of the given RecordId.

Implemented in HeapFile.

Member Data Documentation

◆ schema

Schema* RelationFile::schema
protected

Pointer to the Schema associated with this File. (this is just for fast access to a file's Schema vs. going through the Catalog every time this is needed)


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