SwatDB
Loading...
Searching...
No Matches
hashbucketpage.h
Go to the documentation of this file.
1/*
2 * SwatDB
3 *
4 * @authors: See Contributors.doc for code contributors
5 *
6 * Copyright (c) 2020 Swarthmore College Computer Science Department
7 * Swarthmore PA, Professors Tia Newhall, Ameet Soni
8 */
9
10#ifndef _SWATDB_HASHBUCKETPAGE_H_
11#define _SWATDB_HASHBUCKETPAGE_H_
12
17#include "swatdb_types.h"
18#include "page.h"
19
20class Data;
21class Key;
22
26class HashBucketPage;
27
38
44
50
54 std::uint32_t free_space_begin;
55
59 std::uint32_t free_space_end;
60
64 std::uint32_t size;
65
69 std::uint32_t capacity;
70};
71
76struct SlotInfo{
77
82 std::uint32_t offset;
83
87 std::uint32_t length;
88};
89
95class HashBucketPage : public Page {
96
97 friend class HashBucketPageScanner;
98 friend class HashIndexScanner;
99
100 public:
101
110 HashBucketPage() = delete;
111
116
127
139 std::uint32_t getFreeSpace();
140
150 bool isFull();
151
160 bool isEmpty();
161
184 SlotId insertEntry(Key key, RecordId record_id);
185
200 RecordId getEntry(SlotId slot_id, Data* data);
201
220 void deleteEntry(SlotId slot_id);
221
226
230 void setLevel(Level new_level);
231
237
242 SlotInfo getSlotInfo(SlotId slot_id);
243
248 std::uint32_t getInvalidNum();
249
255
256 private:
257
264
275
295 SlotId _getFreeSlot();
312 SlotInfo* _getSlotInfo(SlotId slot_id);
331 void _insertEntry(SlotId slot_id, Key key, RecordId record_id);
353 void _deleteEntry(SlotId slot_id);
356};
357
358#endif
Definition data.h:26
Definition hashbucketpagescanner.h:26
Definition hashbucketpage.h:95
HashBucketPageHeader getHeader()
THIS METHOD IS FOR DEBUGGING ONLY. Returns this HashBucketPage's header information.
SlotId insertEntry(Key key, RecordId record_id)
Inserts given Key and RecordId to the Page.
void setLevel(Level new_level)
Setter function for the local level of the bucket.
void deleteEntry(SlotId slot_id)
Deletes Entry identified by SlotId.
RecordId getEntry(SlotId slot_id, Data *data)
Gets the entry identified by SlotId.
SlotInfo getSlotInfo(SlotId slot_id)
THIS METHOD IS FOR DEBUGGING ONLY. Returns SlotInfo struct of the given SlotId.
Level getLevel()
Getter function for the local level of the bucket.
void initializeHeader()
Initializes header information after the Page is allocated.
SlotInfo * _getSlotDirectory()
Return pointer to the where slot directory begins (first SlotInfo)
bool isFull()
bool function indicating whether the Page is full.
HashBucketPageHeader * _getPageHeader()
Getter for the Page header.
~HashBucketPage()
Definition hashbucketpage.h:115
void printHashBucketPageState()
THIS METHOD IS FOR DEBUGGING ONLY. Prints the current state of the HashBucketPage.
std::uint32_t getInvalidNum()
THIS METHOD IS FOR DEBUGGING ONLY. Returns number of invalid slots in the HashBucketPage.
HashBucketPage()=delete
Constructor.
std::uint32_t getFreeSpace()
Getter for the amount of free space free on the Page.
bool isEmpty()
bool function indicating whether the Page is empty.
Definition hashindexscanner.h:41
Definition key.h:38
Definition page.h:27
char data[PAGE_SIZE]
char array that stores the page data. Derived classes could map appropriate structures on it.
Definition page.h:60
Definition hashbucketpage.h:33
std::uint32_t capacity
Definition hashbucketpage.h:69
std::uint32_t free_space_begin
Definition hashbucketpage.h:54
Level local_level
Definition hashbucketpage.h:37
PageNum prev_page
Definition hashbucketpage.h:43
PageNum next_page
Definition hashbucketpage.h:49
std::uint32_t size
Definition hashbucketpage.h:64
std::uint32_t free_space_end
Definition hashbucketpage.h:59
Definition swatdb_types.h:70
Definition hashbucketpage.h:76
std::uint32_t offset
Definition hashbucketpage.h:82
std::uint32_t length
Definition hashbucketpage.h:87
std::uint32_t Level
Definition swatdb_types.h:130
std::uint32_t PageNum
Definition swatdb_types.h:38