BTreeIndex class. It implements a B+ Tree index on a single attribute of a relation. This index supports only one scan at a time.
More...
#include <btree.h>
List of all members.
Detailed Description
BTreeIndex class. It implements a B+ Tree index on a single attribute of a relation. This index supports only one scan at a time.
Definition at line 293 of file btree.h.
Constructor & Destructor Documentation
BTreeIndex Constructor. Check to see if the corresponding index file exists. If so, open the file. If not, create it and insert entries for every tuple in the base relation using FileScanner class.
- Parameters:
-
relationName | Name of file. |
outIndexName | Return the name of index file. |
bufMgrIn | Buffer Manager Instance |
attrByteOffset | Offset of attribute, over which index is to be built, in the record |
attrType | Datatype of attribute over which index is built |
- Exceptions:
-
BadIndexInfoException | If the index file already exists for the corresponding attribute, but values in metapage(relationName, attribute byte offset, attribute type etc.) do not match with values received through constructor parameters. |
Definition at line 29 of file btree.cpp.
BTreeIndex Destructor. End any initialized scan, flush index file, after unpinning any pinned pages, from the buffer manager and delete file instance thereby closing the index file. Destructor should not throw any exceptions. All exceptions should be caught in here itself.
Definition at line 43 of file btree.cpp.
Member Function Documentation
Terminate the current scan. Unpin any pinned pages. Reset scan specific variables.
- Exceptions:
-
Definition at line 81 of file btree.cpp.
Insert a new entry using the pair <value,rid>. Start from root to recursively find out the leaf to insert the entry in. The insertion may cause splitting of leaf node. This splitting will require addition of new leaf page number entry into the parent non-leaf, which may in-turn get split. This may continue all the way upto the root causing the root to get split. If root gets split, metapage needs to be changed accordingly. Make sure to unpin pages as soon as you can.
- Parameters:
-
key | Key to insert, pointer to integer/double/char string |
rid | Record ID of a record whose entry is getting inserted into the index. |
Definition at line 51 of file btree.cpp.
Fetch the record id of the next index entry that matches the scan. Return the next record from current page being scanned. If current page has been scanned to its entirety, move on to the right sibling of current page, if any exists, to start scanning that page. Make sure to unpin any pages that are no longer required.
- Parameters:
-
outRid | RecordId of next record found that satisfies the scan criteria returned in this |
- Exceptions:
-
Definition at line 72 of file btree.cpp.
Begin a filtered scan of the index. For instance, if the method is called using ("a",GT,"d",LTE) then we should seek all entries with a value greater than "a" and less than or equal to "d". If another scan is already executing, that needs to be ended here. Set up all the variables for scan. Start from root to find out the leaf page that contains the first RecordID that satisfies the scan parameters. Keep that page pinned in the buffer pool.
- Parameters:
-
lowVal | Low value of range, pointer to integer / double / char string |
lowOp | Low operator (GT/GTE) |
highVal | High value of range, pointer to integer / double / char string |
highOp | High operator (LT/LTE) |
- Exceptions:
-
Definition at line 60 of file btree.cpp.
The documentation for this class was generated from the following files: