SwatDB
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
File Class Referenceabstract

#include <file.h>

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

Public Member Functions

 File (Catalog *catalog, BufferManager *buf_mgr, Schema *schema)
 Constructor. Initializes common state associated with every file, including catalog, buf_mgr, and schema. More...
 
virtual ~File ()
 Destructor. Data members are cleaned up, but none of the dynamically allocated data members are not 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 getMyFid ()
 Returns the FileId of the File. More...
 
SchemagetSchema ()
 Returns the schema of the File. More...
 
PageId getHeaderId ()
 Returns Header PageId. More...
 

Protected Member Functions

void _setMyFid (FileId file_id)
 Sets the file_id and the schema fields of this File. More...
 

Protected Attributes

FileId file_id
 
Catalogcatalog
 
BufferManagerbuf_mgr
 
Schemaschema
 
PageId header_id
 

Friends

class Catalog
 
class FileManager
 

Detailed Description

SwatDB File Class. The base class for all file-type objects in the system. A File is used to represent a relation or index in the system. This base class inludes state and methods that are common to every type of file in the system.

Constructor & Destructor Documentation

◆ File()

File::File ( 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

◆ _setMyFid()

void File::_setMyFid ( FileId  file_id)
protected

Sets the file_id and the schema fields of this File.

NOTE: this is called by

  1. Catalog.createFile so that a File object can be added to the Catalog as part of an entry before the Catalog has determined its fileId (our solution to a chicken and egg problem).
  2. FileManager._loadFile via its constructor when initializing SwatDB from saved db state, we add entries to the Catalog without Files, and the File manager creates File * for them and updates each file's fid field after creation (could just have another constructor to handle this case)
Precondition
The given FileId is valid.
Postcondition
file_id is set to the given value.
Parameters
file_idThe File's FileId.

◆ getHeaderId()

PageId File::getHeaderId ( )

Returns Header PageId.

Precondition
None.
Postcondition
Header PageId of the File is returned.
Returns
The Header PageId.

◆ getMyFid()

FileId File::getMyFid ( )

Returns the FileId of the File.

Returns
The FileId of the File.

◆ getSchema()

Schema* File::getSchema ( )

Returns the schema of the File.

Returns
schema of the File.

Member Data Documentation

◆ buf_mgr

BufferManager* File::buf_mgr
protected

Pointer to the SwatDB BufferManager

◆ catalog

Catalog* File::catalog
protected

Pointer to the SwatDB Catalog

◆ file_id

FileId File::file_id
protected

The File's FileId.

◆ header_id

PageId File::header_id
protected

PageId for the header Page of the File.

◆ schema

Schema* File::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: