SwatDB
|
#include <bm_policies.h>
Public Member Functions | |
MRU (Frame *frame_table) | |
MRU constructor. Initializes pointer to buffer manager's frame_table, creates the free list, sets stack, rep_calls, and avg_frames_checked to 0. | |
~MRU () | |
FrameId | replace () |
Method that implements the Most Recently Used (MRU) replacement policy functionality. | |
void | pin (FrameId frame_id) |
Frame is being pinned with pin count going from 0 to 1. Frame id is removed from stack. | |
void | unpin (FrameId frame_id) |
Frame is being unpinned with pin count going from 1 to 0. Frame id is added to the top of the stack. | |
void | freeFrame (FrameId frame_id) |
The frame is invalidated in the buffer manager, and is added to the free list of frames in the replacement policy. frame_id is also removed from the stack. | |
void | printStats () |
Prints replacement calls, average frames checked when pinning, and max and average size of stack. | |
Public Member Functions inherited from ReplacementPolicy | |
virtual | ~ReplacementPolicy () |
Empty Destructor. | |
virtual void | getRepStats (struct BufferState::ReplacementStats *rep_stats) |
Updates the struct of replacement policy statistics within the buffer state struct. Adds the replacement type, number of calls to the replacement policy, number of calls to getPage or allocatePage average frames checked by each call to policy, and the ref_bit count and clock_hand, which is irrelevant unless the policy is Clock Replacement. | |
void | printFrame (FrameId frame_id) |
THIS METHOD IS FOR DEBUGGING ONLY. Prints Frame state relevant to the replacement policy of a given FrameId, including pin count and ref_bit for Clock Replacement. | |
void | advanceCalls () |
Increment new_page_calls by 1. Called in both allocatePage and getPage in BufferManager. | |
Private Member Functions | |
RepType | _getType () |
Derived class from pure virtual function that returns replacement policy type specific to this derived class. | |
Private Attributes | |
std::list< FrameId > | stack |
int | remove_calls |
Additional Inherited Members | |
Protected Member Functions inherited from ReplacementPolicy | |
void | _createFree () |
Creates a free list for the buffer pool by checking each frame in the buffer pool and checking if it is valid. Used in constructor of each replacement policy. | |
Protected Attributes inherited from ReplacementPolicy | |
Frame * | frame_table |
std::queue< FrameId > | free |
std::uint64_t | rep_calls |
double | avg_frames_checked |
std::uint64_t | new_page_calls |
SwatDB MRU Class. MRU is a derived class of ReplacementPolicy that manages the buffer replacement policy of the DBMS. The Most Recently Used (MRU) algorithm keeps a stack of unpinned pages, choosing the most recently unpinned page for replacement. It is well suited for sequential scans, but it has more overhead than other policies.
MRU::MRU | ( | Frame * | frame_table | ) |
MRU constructor. Initializes pointer to buffer manager's frame_table, creates the free list, sets stack, rep_calls, and avg_frames_checked to 0.
Frame | *frame_table, pointer to frame_table array of BufferManager. |
MRU::~MRU | ( | ) |
Empty Destructor.
|
privatevirtual |
Derived class from pure virtual function that returns replacement policy type specific to this derived class.
Implements ReplacementPolicy.
|
virtual |
The frame is invalidated in the buffer manager, and is added to the free list of frames in the replacement policy. frame_id is also removed from the stack.
FrameId | frame_id of the frame being set invalid. |
Reimplemented from ReplacementPolicy.
|
virtual |
Frame is being pinned with pin count going from 0 to 1. Frame id is removed from stack.
FrameId | frame_id of the frame being unpinned. |
Implements ReplacementPolicy.
|
virtual |
Prints replacement calls, average frames checked when pinning, and max and average size of stack.
Implements ReplacementPolicy.
|
virtual |
Method that implements the Most Recently Used (MRU) replacement policy functionality.
InsufficientSpaceBufMgr | if all pages in the buffer pool are pinned. |
Implements ReplacementPolicy.
|
virtual |
Frame is being unpinned with pin count going from 1 to 0. Frame id is added to the top of the stack.
FrameId | frame_id of the frame being unpinned. |
Implements ReplacementPolicy.
|
private |
Number of times frame has to be removed from stack. Used for calculating avg_frames_checked.
|
private |
List that is used like a stack that holds all unpinned frames.