#include <BufferPool.h>
Public Member Functions | |
ReturnCode | allocateBlock (char **buffer) |
Allocates a scratch block from the buffer pool. | |
ReturnCode | disposeBlock (char *buffer) |
Returns a scratch block to the buffer pool. | |
ReturnCode | lookupBlock (PageFileHandle *fileHandle, int pageNo, char **data) |
Retrieves a page block by its file handle and page number. | |
ReturnCode | setBlockDirty (PageFileHandle *fileHandle, int pageNo, bool isDirty) |
Sets the dirty bit for a page block. | |
ReturnCode | getBlockDirty (PageFileHandle *fileHandle, int pageNo, bool *isDirty) |
Retrieves the dirty bit for a page block. | |
ReturnCode | allocateBlock (PageFileHandle *fileHandle, int pageNo, char **data) |
Allocates a block in the buffer pool. | |
ReturnCode | disposeBlock (PageFileHandle *fileHandle, int pageNo) |
Disposes a block from the buffer pool. | |
ReturnCode | disposeAllBlocks (PageFileHandle *fileHandle) |
Disposes all blocks associated with fileHandle from the pool. | |
ReturnCode | unpinBlock (PageFileHandle *fileHandle, int pageNo) |
Unpins a block in the buffer pool. | |
ReturnCode | getDirtyPageNumber (PageFileHandle *fileHandle, int *pageNo) |
Gets the page number of some dirty block associated with file handle. | |
ReturnCode | getPinCount (PageFileHandle *fileHandle, int pageNo, int *pinCount) |
Gets the pin count for a given block. | |
Static Public Member Functions | |
static BufferPool * | getInstance () |
Gets the singleton instance of this class. |
Buffer pool is a bottom-most component of DavisDB, and manages the in- memory buffer pool of pages. The buffer pool consists of PF_BUFFER_SIZE blocks of memory, each of size PF_PAGE_SIZE. This pool can be be used for "scratch" pages, allocated and freed via allocateBlock and disposeBlock, and also for pages associated with FileHandle objects. For the latter kind of pages, a pin count is maintained, and the page is not considered free unless its pin count is zero. When a new page is requested from the pool, space is freed up as necessary by flushing free pages to disk using an LRU replacement policy. The actual flushing is performed by the FileHandle object associated with the page to be flushed. This is a singleton class.
ReturnCode BufferPool::allocateBlock | ( | char ** | buffer | ) |
Allocates a scratch block from the buffer pool.
buffer | Out parameter for the scratch block. |
ReturnCode BufferPool::disposeBlock | ( | char * | buffer | ) |
Returns a scratch block to the buffer pool.
buffer | The pointer to the scratch block. |
ReturnCode BufferPool::lookupBlock | ( | PageFileHandle * | fileHandle, | |
int | pageNo, | |||
char ** | data | |||
) |
Retrieves a page block by its file handle and page number.
fileHandle | The file handle associated with the block. | |
pageNo | The page number associated with the block. | |
data | Out parameter for the block. |
ReturnCode BufferPool::setBlockDirty | ( | PageFileHandle * | fileHandle, | |
int | pageNo, | |||
bool | isDirty | |||
) |
Sets the dirty bit for a page block.
fileHandle | The file handle associated with the block. | |
pageNo | The page number associated with the block. | |
isDirty | true means "dirty", false means "not dirty." |
ReturnCode BufferPool::getBlockDirty | ( | PageFileHandle * | fileHandle, | |
int | pageNo, | |||
bool * | isDirty | |||
) |
Retrieves the dirty bit for a page block.
fileHandle | The file handle associated with the block. | |
pageNo | The page number associated with the block. | |
isDirty | Out parameter for the dirty bit. |
ReturnCode BufferPool::allocateBlock | ( | PageFileHandle * | fileHandle, | |
int | pageNo, | |||
char ** | data | |||
) |
Allocates a block in the buffer pool.
fileHandle | The file handle to associate with the block. | |
pageNo | The page number to associate with the block. | |
data | Out parameter for the allocated block. |
ReturnCode BufferPool::disposeBlock | ( | PageFileHandle * | fileHandle, | |
int | pageNo | |||
) |
Disposes a block from the buffer pool.
fileHandle | The file handle associated with the block | |
pageNo | The page number associated with the block |
ReturnCode BufferPool::disposeAllBlocks | ( | PageFileHandle * | fileHandle | ) |
Disposes all blocks associated with fileHandle from the pool.
fileHandle | The file handle |
ReturnCode BufferPool::unpinBlock | ( | PageFileHandle * | fileHandle, | |
int | pageNo | |||
) |
Unpins a block in the buffer pool.
fileHandle | The file handle associated with the block. | |
pageNo | The page number associated with the block. |
ReturnCode BufferPool::getDirtyPageNumber | ( | PageFileHandle * | fileHandle, | |
int * | pageNo | |||
) |
Gets the page number of some dirty block associated with file handle.
fileHandle | The file handle whose pages are of interest. | |
pageNo | Out parameter for the page number. |
ReturnCode BufferPool::getPinCount | ( | PageFileHandle * | fileHandle, | |
int | pageNo, | |||
int * | pinCount | |||
) |
Gets the pin count for a given block.
fileHandle | The file handle associated with the block. | |
pageNo | The page number associated with the block. | |
pinCount | Out parameter for the pin count. |
BufferPool * BufferPool::getInstance | ( | ) | [static] |
Gets the singleton instance of this class.
Gets the static singleton instance of this class.