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

#include <indexfile.h>

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

Public Member Functions

 IndexFile (Catalog *catalog, BufferManager *buf_mgr, FileId relation, std::vector< std::string > field_list)
 Constructor for IndexFile class.
 
 IndexFile (Catalog *catalog, BufferManager *buf_mgr, FileId relation, std::vector< FieldId > field_list)
 Constructor for IndexFile class.
 
virtual ~IndexFile ()
 Destructor. Data members are cleaned up, but none of the dynamically allocated data members are deleted. The underlying Unix file is not deleted.
 
SearchKeyFormatgetKeyFormat ()
 Returns the key format of the Index.
 
virtual void insertEntry (Key key, RecordId record_id)=0
 A virtual method for inserting a <Key, RecordId> entry into the IndexFile.
 
virtual std::vector< RecordIdgetEntries (Key key)=0
 A virtual method for getting a list of entries with the given key.
 
virtual void deleteEntry (Key key, RecordId record_id)=0
 A virtual method for deleting an entry of the given Key and RecordId.
 
virtual void deleteKey (Key key)=0
 A virtual method for deleting all entires with the given key.
 
- 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

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

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 IndexFile Class. Represents index file in the system. It is an abstract class from which lower level index file implementations (B+ tree and Hash index) inherit. abstract methods for inserting and deleting entries are defined. There may be other lower level methods that are implementation specific (and hence not defined here).

Constructor & Destructor Documentation

◆ IndexFile() [1/2]

IndexFile::IndexFile ( Catalog catalog,
BufferManager buf_mgr,
FileId  relation,
std::vector< std::string >  field_list 
)

Constructor for IndexFile class.

Precondition
A valid Catalog pointer and BufferManager pointer are provided as inputs.
Postcondition
IndexFile object is constructed. Catalog, BufferManager,
and relation FileId are set to the given values. Appropriate key format is constructed based on field_list. FileId and Header Page data are set later.
Parameters
catalogPointer to the SwatDB Catalog object.
buf_mgrPointer to the SwatDB BufferManager object.
relationFileId of the relation of which the index is created.
field_listThe list of the attributes for which the index is created.

◆ IndexFile() [2/2]

IndexFile::IndexFile ( Catalog catalog,
BufferManager buf_mgr,
FileId  relation,
std::vector< FieldId field_list 
)

Constructor for IndexFile class.

Precondition
A valid Catalog pointer and BufferManager pointer are provided as inputs.
Postcondition
IndexFile object is constructed. Catalog, BufferManager,
and relation FileId are set to the given values. Appropriate key format is constructed based on field_list. FileId and Header Page data are set later.
Parameters
catalogPointer to the SwatDB Catalog object.
buf_mgrPointer to the SwatDB BufferManager object.
relationFileId of the relation of which the index is created.
field_listThe list of the attributes for which the index is created.

Member Function Documentation

◆ deleteEntry()

virtual void IndexFile::deleteEntry ( Key  key,
RecordId  record_id 
)
pure virtual

A virtual method for deleting an entry of the given Key and RecordId.

Parameters
keyKey of the entry to be deleted.
record_idRecordId of the entry to be deleted.

Implemented in HashIndexFile.

◆ deleteKey()

virtual void IndexFile::deleteKey ( Key  key)
pure virtual

A virtual method for deleting all entires with the given key.

Parameters
keyKey and the RecordId of the entries to be deleted.

Implemented in HashIndexFile.

◆ getEntries()

virtual std::vector< RecordId > IndexFile::getEntries ( Key  key)
pure virtual

A virtual method for getting a list of entries with the given key.

Parameters
keyKey of the entries to be retrieved.

Implemented in HashIndexFile.

◆ getKeyFormat()

SearchKeyFormat * IndexFile::getKeyFormat ( )

Returns the key format of the Index.

Returns
key_format of the Index.

◆ insertEntry()

virtual void IndexFile::insertEntry ( Key  key,
RecordId  record_id 
)
pure virtual

A virtual method for inserting a <Key, RecordId> entry into the IndexFile.

Parameters
keyKey of the entry to be inserted.
record_idRecordId of the entry to be inserted.

Implemented in HashIndexFile.

Member Data Documentation

◆ key_format

SearchKeyFormat* IndexFile::key_format
protected

Format of the key.

◆ relation

FileId IndexFile::relation
protected

FileId of the relation the index belongs to.


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