12#ifndef _SWATDB_BUFMGER_H_
13#define _SWATDB_BUFMGER_H_
21#include <unordered_map>
471 void _printFrameHelper(
FrameId frame_id);
void setDirty(PageId page_id)
Set the Page of the given PageId dirty.
void deallocateAnonymousPage(PageId page_id)
Removes the Page of the given anonymous PageId from the buffer pool, and deallocates the Page from th...
void flushPage(PageId page_id)
Flushes the Page of the given PageId to disk.
void printValidFrames()
THIS METHOD IS FOR DEBUGGING ONLY. Prints Frame state of every valid Frame in the buffer pool,...
~BufferManager()
BufferManager destructor.
std::pair< Page *, PageId > allocateAnonymousPage()
Allocates an anonymous Page for the file of given FileId. The Page is allocated both in the buffer po...
void printPage(PageId page_id)
THIS METHOD IS FOR DEBUGGING ONLY. Prints Frame state of given PageId, including FrameId,...
void createFile(FileId file_id)
Calls createFile() method on the DiskManager to create new Unix file that corresponds to the given Fi...
ReplacementPolicy * replacement_pol
Definition bufmgr.h:429
void clearBuffer()
THIS METHOD IS FOR DEBUGGING ONLY. Clears the entire buffer pool, resetting all frames and removing p...
void printBufferState()
THIS METHOD IS FOR DEBUGGING ONLY. Prints current buffer state, including total number of pages,...
void printReplacementStats()
This method is for performance tests. Prints number of calls to replacment policy,...
BufferManager(DiskManager *disk_mgr, RepType rep_type)
BufferManager constructor. Initializes the buf_pool and frame_table, and stores a pointer to SwatDB's...
void printAllFrames()
THIS METHOD IS FOR DEBUGGING ONLY. Prints Frame state of every Frame in the buffer pool,...
Frame frame_table[BUF_SIZE]
Definition bufmgr.h:412
void removeFile(FileId file_id)
Calls removeFile() method on the DiskManager. Checks that none of the file's pages are pinned in the ...
BufferMap buf_map
Definition bufmgr.h:406
std::uint32_t getNumUnpinned()
Return the amount of unpinned pages in the buffer pool.
void printFrame(FrameId frame_id)
THIS METHOD IS FOR DEBUGGING ONLY. Prints Frame state of given FrameId, including pin count,...
Page * getPage(PageId page_id)
Gets Page by page_id, pins the Page, and returns a pointer to the Page object.
std::mutex buf_map_mtx
Definition bufmgr.h:437
BufferState getBufferState()
THIS METHOD IS FOR DEBUGGING ONLY. Returns the current state of the buffer pool.
void deallocatePage(PageId page_id)
Removes the Page of the given PageId from the buffer pool, and deallocates the Page from the appopria...
std::pair< Page *, PageId > allocatePage(FileId file_id)
Allocates a Page for the file of given FileId. The Page is allocated both in the buffer pool,...
Page buf_pool[BUF_SIZE]
Definition bufmgr.h:417
DiskManager * disk_mgr
Definition bufmgr.h:423
void releasePage(PageId page_id, bool dirty)
Unpins a Page in the buffer pool.
Definition bm_buffermap.h:38
Definition bm_replacement.h:29
std::uint32_t ref_bit
Definition bufmgr.h:103
double avg_frames_checked
Definition bufmgr.h:98
std::uint64_t new_page_calls
Definition bufmgr.h:92
std::uint64_t rep_calls
Definition bufmgr.h:87
RepType rep_type
Definition bufmgr.h:83
std::uint32_t clock_hand
Definition bufmgr.h:108
std::uint32_t pinned
Definition bufmgr.h:66
std::uint32_t total
Definition bufmgr.h:56
std::uint32_t valid
Definition bufmgr.h:61
std::uint32_t dirty
Definition bufmgr.h:76
std::uint32_t unpinned
Definition bufmgr.h:71
Definition swatdb_types.h:54
std::uint32_t FrameId
Index of each frame in the bufferpool of BufferManager.
Definition swatdb_types.h:44
const std::uint32_t BUF_SIZE
Definition swatdb_types.h:292
std::uint32_t FileId
Definition swatdb_types.h:33
RepType
Definition swatdb_types.h:167