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 | |
BufferManager (std::uint32_t bufs) | |
~BufferManager () | |
void | readPage (File *file, const PageId PageNo, Page *&page) |
void | unPinPage (File *file, const PageId PageNo, const bool dirty) |
void | allocatePage (File *file, PageId &PageNo, Page *&page) |
void | flushFile (const File *file) |
void | disposePage (File *file, const PageId PageNo) |
void | printSelf () |
BufferStats & | getBufferStats () |
void | clearBufferStats () |
Public Attributes | |
Page * | bufPool |
The central class which manages the buffer pool including frame allocation and deallocation to pages in the file.
wiscdb::BufferManager::BufferManager | ( | std::uint32_t | bufs | ) |
Constructor of BufferManager class
Definition at line 51 of file buffer.cpp.
Destructor of BufferManager class
Definition at line 69 of file buffer.cpp.
void wiscdb::BufferManager::allocatePage | ( | File * | file, |
PageId & | PageNo, | ||
Page *& | page | ||
) |
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 90 of file buffer.cpp.
void wiscdb::BufferManager::clearBufferStats | ( | ) | [inline] |
void wiscdb::BufferManager::disposePage | ( | File * | file, |
const PageId | PageNo | ||
) |
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 86 of file buffer.cpp.
void wiscdb::BufferManager::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 an exception is thrown.
file | File object to flush to disk |
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 83 of file buffer.cpp.
BufferStats& wiscdb::BufferManager::getBufferStats | ( | ) | [inline] |
void wiscdb::BufferManager::printSelf | ( | ) |
Print member variable values.
Definition at line 93 of file buffer.cpp.
void wiscdb::BufferManager::readPage | ( | File * | file, |
const PageId | PageNo, | ||
Page *& | page | ||
) |
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, its pin count is increased and a 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 76 of file buffer.cpp.
void wiscdb::BufferManager::unPinPage | ( | File * | file, |
const PageId | PageNo, | ||
const bool | dirty | ||
) |
Unpin a page from memory when one requesting application no longer requires 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 80 of file buffer.cpp.