WiscDB
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends
Public Member Functions | Public Attributes
wiscdb::BufferManager Class Reference

The central class which manages the buffer pool including frame allocation and deallocation to pages in the file. More...

#include <buffer.h>

List of all members.

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 ()
BufferStatsgetBufferStats ()
void clearBufferStats ()

Public Attributes

PagebufPool

Detailed Description

The central class which manages the buffer pool including frame allocation and deallocation to pages in the file.

Definition at line 131 of file buffer.h.


Constructor & Destructor Documentation

wiscdb::BufferManager::BufferManager ( std::uint32_t  bufs)

Constructor of BufferManager class

Destructor of BufferManager class


Member Function Documentation

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.

Parameters:
fileFile object
PageNoPage number. The number assigned to the page in the file is returned via this reference.
pageReference to page pointer. The newly allocated in-memory Page object is returned via this reference.

Clear buffer pool usage statistics

Definition at line 271 of file buffer.h.

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.

Parameters:
fileFile object
PageNoPage number
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.

Parameters:
fileFile object to flush to disk
Exceptions:
PagePinnedExceptionIf any page of the file is pinned in the buffer pool
BadBufferExceptionIf any frame allocated to the file is found to be invalid

Get buffer pool usage statistics

Definition at line 263 of file buffer.h.

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.

Parameters:
fileFile object
PageNoPage number in the file to be read
pageReference to page pointer. Used to fetch the Page object in which requested page from file is read in.
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.

Parameters:
fileFile object
PageNoPage number
dirtyTrue if the page to be unpinned needs to be marked dirty
Exceptions:
PageNotPinnedExceptionIf the page is not already pinned

Member Data Documentation

Actual buffer pool of Pages. A table of Page objects, with each index corresponding to Frame at the same index of frameTable.

Definition at line 182 of file buffer.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends