#include <bm_policies.h>
|
| ClockRandom (Frame *frame_table) |
| Clock Random constructor. Initializes pointer to buffer manager's frame_table, creates the free list, sets rep_calls and avg_frames_checked to 0.
|
|
| ~ClockRandom () |
|
FrameId | replace () |
| Method that implements the Clock Random replacement policy functionality.
|
|
void | pin (FrameId frame_id) |
| Frame is being pinned with pin count going from 0 to 1. Clock Random policy has nothing to do here, but an empty method must exist for BufferManager to call.
|
|
void | unpin (FrameId frame_id) |
| Frame is being unpinned with pin count going from 1 to 0. Clock Random policy has nothing to do here, but an empty method must exist for BufferManager to call.
|
|
void | printStats () |
| Prints average frames checked, replacement calls, summary stats on randomness.
|
|
virtual | ~ReplacementPolicy () |
| Empty Destructor.
|
|
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.
|
|
void | advanceCalls () |
| Increment new_page_calls by 1. Called in both allocatePage and getPage in BufferManager.
|
|
|
RepType | _getType () |
| Derived class from pure virtual function that returns replacement policy type specific to this derived class.
|
|
SwatDB Clock Random Class. Clock Random is a derived class of ReplacementPolicy that manages the buffer replacement policy of the DBMS. The random algorithm randomly generates a frame id to check if they are eligible for replacement. If not it iterates throught the buf pool starting from that point until it finds an eligible frame.
◆ ClockRandom()
ClockRandom::ClockRandom |
( |
Frame * |
frame_table | ) |
|
Clock Random constructor. Initializes pointer to buffer manager's frame_table, creates the free list, sets rep_calls and avg_frames_checked to 0.
- Precondition
- BufferManager constructor is being called, frame_table parameter points to an initialized frame_table object.
- Postcondition
- A Clock Random policy object will be initialized with member variables initialized.
- Parameters
-
◆ ~ClockRandom()
ClockRandom::~ClockRandom |
( |
| ) |
|
◆ _getType()
Derived class from pure virtual function that returns replacement policy type specific to this derived class.
- Returns
- RepType ClockRandomT.
Implements ReplacementPolicy.
◆ pin()
void ClockRandom::pin |
( |
FrameId |
frame_id | ) |
|
|
virtual |
Frame is being pinned with pin count going from 0 to 1. Clock Random policy has nothing to do here, but an empty method must exist for BufferManager to call.
- Precondition
- A page in the buffer pool has been pinned, and the pin count of that frame has increased from 0 to 1.
- Postcondition
- Nothing.
- Parameters
-
FrameId | frame_id of the frame being unpinned. |
Implements ReplacementPolicy.
◆ printStats()
void ClockRandom::printStats |
( |
| ) |
|
|
virtual |
Prints average frames checked, replacement calls, summary stats on randomness.
Implements ReplacementPolicy.
◆ replace()
Method that implements the Clock Random replacement policy functionality.
- 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, a random frame is selected and evaluated for eligibility. If it is pinned, iterate through buf pool starting from that point. If all pages are pinned, an exception is thrown.
- Returns
- FrameID of the frame that is eligible for replacement in the buffer pool.
- Exceptions
-
Implements ReplacementPolicy.
◆ unpin()
void ClockRandom::unpin |
( |
FrameId |
frame_id | ) |
|
|
virtual |
Frame is being unpinned with pin count going from 1 to 0. Clock Random policy has nothing to do here, but an empty method must exist for BufferManager to call.
- Precondition
- A page in the buffer pool has been unpinned from pin count 1 to 0.
- Postcondition
- Nothing.
- Parameters
-
FrameId | frame_id of the frame being unpinned. |
Implements ReplacementPolicy.
◆ times_chosen
Parallel array to frame_table that stores number of times each frame_id is chosen for replacement. Is useful for determining randomness.
The documentation for this class was generated from the following file: