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
Destructor of BufferManager class
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.
void wiscdb::BufferManager::clearBufferStats | ( | ) | [inline] |
void wiscdb::BufferManager::disposePage | ( | File * | file, |
const PageId | PageNo | ||
) |
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 |
BufferStats& wiscdb::BufferManager::getBufferStats | ( | ) | [inline] |
void wiscdb::BufferManager::printSelf | ( | ) |
Print member variable values.
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.
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 |