SwatDB
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Friends | List of all members
HashBucketPage Class Reference

#include <hashbucketpage.h>

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

Public Member Functions

 HashBucketPage ()=delete
 Constructor.
 
 ~HashBucketPage ()
 
void initializeHeader ()
 Initializes header information after the Page is allocated.
 
std::uint32_t getFreeSpace ()
 Getter for the amount of free space free on the Page.
 
bool isFull ()
 bool function indicating whether the Page is full.
 
bool isEmpty ()
 bool function indicating whether the Page is empty.
 
SlotId insertEntry (Key key, RecordId record_id)
 Inserts given Key and RecordId to the Page.
 
RecordId getEntry (SlotId slot_id, Data *data)
 Gets the entry identified by SlotId.
 
void deleteEntry (SlotId slot_id)
 Deletes Entry identified by SlotId.
 
Level getLevel ()
 Getter function for the local level of the bucket.
 
void setLevel (Level new_level)
 Setter function for the local level of the bucket.
 
HashBucketPageHeader getHeader ()
 THIS METHOD IS FOR DEBUGGING ONLY. Returns this HashBucketPage's header information.
 
SlotInfo getSlotInfo (SlotId slot_id)
 THIS METHOD IS FOR DEBUGGING ONLY. Returns SlotInfo struct of the given SlotId.
 
std::uint32_t getInvalidNum ()
 THIS METHOD IS FOR DEBUGGING ONLY. Returns number of invalid slots in the HashBucketPage.
 
void printHashBucketPageState ()
 THIS METHOD IS FOR DEBUGGING ONLY. Prints the current state of the HashBucketPage.
 
- Public Member Functions inherited from Page
 Page ()
 Constructor.
 
 ~Page ()
 Destructor.
 
char * getData ()
 Get function for the data char array.
 

Private Member Functions

HashBucketPageHeader_getPageHeader ()
 Getter for the Page header.
 
SlotInfo_getSlotDirectory ()
 Return pointer to the where slot directory begins (first SlotInfo)
 

Friends

class HashBucketPageScanner
 
class HashIndexScanner
 

Additional Inherited Members

- Protected Attributes inherited from Page
char data [PAGE_SIZE]
 char array that stores the page data. Derived classes could map appropriate structures on it.
 

Detailed Description

SwatDB HashBucketPage Class. HashBucketPage inherits from base Page class and instantiates hash bucket, collection of which, form buckets of hash index.

Constructor & Destructor Documentation

◆ HashBucketPage()

HashBucketPage::HashBucketPage ( )
delete

Constructor.

Constructor should never be called. It should be always the case that base class Page constructor is called by the BufferManager when initializing bufferpool. HashBucketPage Pointer is casted to whatever Page pointer returned by the BufferManager

◆ ~HashBucketPage()

HashBucketPage::~HashBucketPage ( )
inline

Destructor

Member Function Documentation

◆ _getPageHeader()

HashBucketPageHeader * HashBucketPage::_getPageHeader ( )
private

Getter for the Page header.

Returns
Pointer to the HashBucketPageHeader of the Page (beginning of data array).

◆ _getSlotDirectory()

SlotInfo * HashBucketPage::_getSlotDirectory ( )
private

Return pointer to the where slot directory begins (first SlotInfo)

Precondition
None
Postcondition
Pointer to first SlotInfo is returned.
Parameters
slot_idSlotId of SlotInfo* that is returned.
Returns
Pointer to the first SlotInfo in slot directory.

◆ deleteEntry()

void HashBucketPage::deleteEntry ( SlotId  slot_id)

Deletes Entry identified by SlotId.

Precondition
A valid SlotId is provided as input.
Postcondition
The entry in that slot is removed from the page, and its slot directory entry is freed. The remaining entries on the page are compacted at the end of the page. Page meta data and slot directory entries are updated to reflect the deletion this entry. The total amount of freespace on the page increases. The slot directory may shrink by one or more SlotInfo entries as a result of this call.
Parameters
slot_idSlotId of the entry to be deleted.
Exceptions
InvalidSlotIdHashBucketPageIf SlotId is invalid (SlotId is out of range or SlotInfo of the given SlotId has INVALID_SLOT_OFFSET).

◆ getEntry()

RecordId HashBucketPage::getEntry ( SlotId  slot_id,
Data data 
)

Gets the entry identified by SlotId.

*

Precondition
A valid SlotId is provided as input and a valid Data* with capacity that is greater than maximum size of any Key stored in the Page is passed.
Postcondition
The data contains a serialized key of the requsted entry stored in the Page.
Parameters
slot_idSlotId of the Entry to be retrieved
Exceptions
InvalidSlotIdHashBucketPageIf SlotId is out of range or SlotInfo of the given SlotId has INVALID_SLOT_OFFSET.

◆ getFreeSpace()

std::uint32_t HashBucketPage::getFreeSpace ( )

Getter for the amount of free space free on the Page.

Precondition
None.
Postcondition
The amount of free space in bytes on the Page is returned. If there is no free slot, sizeof(SlotInfo) is subtracted from the free space returned (accounting extra space occupied if new slot is allocated). If free space is less than sizeof(SlotInfo), 0 is returned.
Returns
Amount of free space in bytes on the Page.

◆ initializeHeader()

void HashBucketPage::initializeHeader ( )

Initializes header information after the Page is allocated.

Precondition
None
Postcondition
Page header is initialized such that local_level is set to 0, prev_page and next_page are set to INVALID_PAGE_NUM, free_space_begin is set to sizeof(HashBucektPageHeader), free_space_end is set to PAGE_SIZE, size and capacity are set to 0.

◆ insertEntry()

SlotId HashBucketPage::insertEntry ( Key  key,
RecordId  record_id 
)

Inserts given Key and RecordId to the Page.

If there is enough free space on the Page, and valid Key is passed (the Data value has non-zero length), then the data are inserted into the page.

Precondition
The slot directory has m used slots in its slot directory and all m entrie are compacted at the bottom of the page.
Postcondition
After a successful insert, it has m+1 used slots in its solt directory (possibly increasing the slot directory size by one entry), and all m+1 entries are compacted at the bottom of the page.
Parameters
keyKey to be inserted.
Returns
SlotId of the slot the Entry is inserted to.
Exceptions
InsufficientSpaceHashBucketPageIf there is not enough space to insert the entry on the page.
EmptyDataHashBucketPageIf the passed entry data has size of 0.

◆ isEmpty()

bool HashBucketPage::isEmpty ( )

bool function indicating whether the Page is empty.

Precondition
None.
Postcondition
true is returned if size is 0. Else false is returned.
Returns
bool indicating whether the Page is empty.

◆ isFull()

bool HashBucketPage::isFull ( )

bool function indicating whether the Page is full.

Precondition
None.
Postcondition
true is returned if used space/PAGE_SIZE exceeds MAX_HEAP_PAGE_LOAD and false is returned otherwise.
Returns
bool indicating whether the Page is full.

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