#include <bm_replacement.h>
|
virtual | ~ReplacementPolicy () |
| Empty Destructor.
|
|
virtual FrameId | replace ()=0 |
| Pure virtual method that implements core replacement policy functionality in child classes.
|
|
virtual void | pin (FrameId frame_id)=0 |
| Pure virtual method that implements any necessary update to replacement policy state following the pinning of a page in the buffer pool.
|
|
virtual void | unpin (FrameId frame_id)=0 |
| Pure virtual method that implements any necessary update to replacement policy state following the unpinning of a page in the buffer pool.
|
|
virtual void | freeFrame (FrameId frame_id) |
| Virtual method that implements any necessary update to replacement policy state following the deallocation of a page in the buffer pool. The frame is invalidated in the buffer manager, and is added to the free list of frames in the replacement policy. Some policies must implement additional functionality.
|
|
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.
|
|
virtual void | printStats ()=0 |
| Pure virtual method for printing relevant stats for the specific derived class.
|
|
void | advanceCalls () |
| Increment new_page_calls by 1. Called in both allocatePage and getPage in BufferManager.
|
|
|
virtual RepType | _getType ()=0 |
| Returns the type of a given replacement policy. Used to fill struct of replacement statistics.
|
|
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.
|
|
SwatDB ReplacementPolicy Class. ReplacementPolicy is an abstract class that manages the buffer replacement policy of the DBMS. Individual child classes implemement each policy. Methods work within the buffer manager to choose frames to replace from the frame table.
◆ _createFree()
void ReplacementPolicy::_createFree |
( |
| ) |
|
|
protected |
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.
- Precondition
- None.
- Postcondition
- Free list member variable of policy is filled.
◆ _getType()
virtual RepType ReplacementPolicy::_getType |
( |
| ) |
|
|
protectedpure virtual |
Returns the type of a given replacement policy. Used to fill struct of replacement statistics.
- Returns
- RepType of replacement policy.
Implemented in Clock, Random, MRU, LRU, and ClockRandom.
◆ freeFrame()
virtual void ReplacementPolicy::freeFrame |
( |
FrameId |
frame_id | ) |
|
|
virtual |
Virtual method that implements any necessary update to replacement policy state following the deallocation of a page in the buffer pool. The frame is invalidated in the buffer manager, and is added to the free list of frames in the replacement policy. Some policies must implement additional functionality.
- Precondition
- A page in the buffer pool has been deallocated
- Postcondition
- The replacement policy state is updated to reflect the freeing of a specific frame. The state updates vary for different policies.
Reimplemented in Clock, MRU, and LRU.
◆ getRepStats()
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.
Reimplemented in Clock.
◆ pin()
virtual void ReplacementPolicy::pin |
( |
FrameId |
frame_id | ) |
|
|
pure virtual |
Pure virtual method that implements any necessary update to replacement policy state following the pinning of a page in the buffer pool.
- Precondition
- A page in the buffer pool has been pinned, and the pin count of that frame has increased from 0 to 1.
- Postcondition
- The replacement policy state is updated to reflect the pinning of a specific page. The state updates vary for the different policies
Implemented in Clock, Random, MRU, LRU, and ClockRandom.
◆ printStats()
virtual void ReplacementPolicy::printStats |
( |
| ) |
|
|
pure virtual |
◆ replace()
virtual FrameId ReplacementPolicy::replace |
( |
| ) |
|
|
pure virtual |
Pure virtual method that implements core replacement policy functionality in child classes.
- Precondition
- The replacement policy has been invoked. The buffer manager is attempting to add a frame to the buffer pool. The buffer map is locked.
- Postcondition
- If there is a free (invalid) frame, that FrameID is chosen for replacement and is returned. Else, the replacement policy is invoked and used to determine and return the FrameID of an unpinned Frame which is eligible for replacement. If all pages are pinned, an exception is thrown.
- Returns
- FrameID of the frame that is eligible for replacement in the buffer pool.
- Exceptions
-
Implemented in Clock, Random, MRU, LRU, and ClockRandom.
◆ unpin()
virtual void ReplacementPolicy::unpin |
( |
FrameId |
frame_id | ) |
|
|
pure virtual |
Pure virtual method that implements any necessary update to replacement policy state following the unpinning of a page in the buffer pool.
- Precondition
- A page in the buffer pool has been unpinned from pin count 1 to 0.
- Postcondition
- The replacement policy state is updated to reflect the unpinning of a specific page. The state updates vary for the different policies
Implemented in Clock, Random, MRU, LRU, and ClockRandom.
◆ avg_frames_checked
double ReplacementPolicy::avg_frames_checked |
|
protected |
Running average of the amount of frames checked per call to policy. Frames in the free list do not contribute to this average.
◆ frame_table
Frame* ReplacementPolicy::frame_table |
|
protected |
Pointer to the frame table in the buffer manager
◆ free
std::queue<FrameId> ReplacementPolicy::free |
|
protected |
List of all free pages in the buffer pool.
◆ new_page_calls
std::uint64_t ReplacementPolicy::new_page_calls |
|
protected |
Running total of the amount of calls to getPage or allocatePage in the buf_mgr. Allows calculation of percentage of getPages where replacement was required.
◆ rep_calls
std::uint64_t ReplacementPolicy::rep_calls |
|
protected |
Running total of the amount of calls to the replacement policy since the constructor.
The documentation for this class was generated from the following file: