The central class which manages the buffer pool including frame allocation and deallocation to pages in the file. More...
#include <buffer.h>
Public Member Functions | |
BufMgr (std::uint32_t bufs) | |
~BufMgr () | |
void | readPage (File *file, const PageId PageNo, Page *&page) |
void | unPinPage (File *file, const PageId PageNo, const bool dirty) |
void | allocPage (File *file, PageId &PageNo, Page *&page) |
void | flushFile (const File *file) |
void | disposePage (File *file, const PageId PageNo) |
void | printSelf () |
BufStats & | getBufStats () |
void | clearBufStats () |
Public Attributes | |
Page * | bufPool |
The central class which manages the buffer pool including frame allocation and deallocation to pages in the file.
badgerdb::BufMgr::BufMgr | ( | std::uint32_t | bufs | ) |
badgerdb::BufMgr::~BufMgr | ( | ) |
Allocates a new, empty page in the file and returns the Page object. The newly allocated page is also assigned a frame in the buffer pool.
file | File object |
PageNo | Page number. The number assigned to the page in the file is returned via this reference. |
page | Reference to page pointer. The newly allocated in-memory Page object is returned via this reference. |
Definition at line 177 of file buffer.cpp.
|
inline |
Clear buffer pool usage statistics
Delete page from file and also from buffer pool if present. Since the page is entirely deleted from file, its unnecessary to see if the page is dirty.
Definition at line 191 of file buffer.cpp.
void badgerdb::BufMgr::flushFile | ( | const File * | file | ) |
Writes out all dirty pages of the file to disk. All the frames assigned to the file need to be unpinned from buffer pool before this function can be successfully called. Otherwise Error returned.
file | File object |
PagePinnedException | If any page of the file is pinned in the buffer pool |
BadBufferException | If any frame allocated to the file is found to be invalid |
Definition at line 148 of file buffer.cpp.
|
inline |
void badgerdb::BufMgr::printSelf | ( | void | ) |
Reads the given page from the file into a frame and returns the pointer to page. If the requested page is already present in the buffer pool pointer to that frame is returned otherwise a new frame is allocated from the buffer pool for reading the page.
file | File object |
PageNo | Page number in the file to be read |
page | Reference to page pointer. Used to fetch the Page object in which requested page from file is read in. |
Definition at line 117 of file buffer.cpp.
Unpin a page from memory since it is no longer required for it to remain in memory.
file | File object |
PageNo | Page number |
dirty | True if the page to be unpinned needs to be marked dirty |
PageNotPinnedException | If the page is not already pinned |
Definition at line 133 of file buffer.cpp.
Page* badgerdb::BufMgr::bufPool |