11 #include "bufHashTbl.h"
12 #include "exceptions/hash_already_present_exception.h"
13 #include "exceptions/hash_not_found_exception.h"
14 #include "exceptions/hash_table_exception.h"
18 int BufHashTbl::hash(
const File* file,
const PageId pageNo)
22 value = (tmp + pageNo) % HTSIZE;
31 for(
int i=0; i < HTSIZE; i++)
37 for(
int i = 0; i < HTSIZE; i++) {
50 int index = hash(file, pageNo);
54 if (tmpBuc->
file == file && tmpBuc->
pageNo == pageNo)
56 tmpBuc = tmpBuc->next;
66 tmpBuc->
next = ht[index];
72 int index = hash(file, pageNo);
75 if (tmpBuc->
file == file && tmpBuc->
pageNo == pageNo)
80 tmpBuc = tmpBuc->
next;
87 int index = hash(file, pageNo);
93 if (tmpBuc->
file == file && tmpBuc->
pageNo == pageNo)
98 ht[index] = tmpBuc->
next;
106 tmpBuc = tmpBuc->
next;
An exception that is thrown when a new entry to be inserted in the hash table is already present in i...
const std::string & filename() const
BufHashTbl(const int htSize)
std::uint32_t FrameId
Identifier for a frame in buffer pool.
Declarations for buffer pool hash table.
Class which represents a file in the filesystem containing database pages.
std::uint32_t PageId
Identifier for a page in a file.
An exception that is thrown when some unexpected error occurs in the hash table.
bool lookup(const File *file, const PageId pageNo, FrameId &frameNo)
void remove(const File *file, const PageId pageNo)
void insert(const File *file, const PageId pageNo, const FrameId frameNo)
An exception that is thrown when an entry being looked up in the hash table is not present in it...