SwatDB
Loading...
Searching...
No Matches
bm_replacement.h
Go to the documentation of this file.
1/*
2 * SwatDB
3 *
4 * @authors: See Contributors.doc for code contributors
5 *
6 * Copyright (c) 2020,2025 Swarthmore College Computer Science Department
7 * Swarthmore PA, Professors Tia Newhall, Ameet Soni
8 */
9
10#ifndef _SWATDB_BM_REPLACEMENT_H_
11#define _SWATDB_BM_REPLACEMENT_H_
12
18#include <utility>
19#include "swatdb_types.h"
20#include "bufmgr.h" // need for BufferState stats struct
21
30
31
32 public:
33
38
59 virtual FrameId replace() = 0;
60
72 virtual void pin(FrameId frame_id) = 0;
73
85 virtual void unpin(FrameId frame_id) = 0;
86
100 virtual void freeFrame(FrameId frame_id);
101
102
111 virtual void getRepStats(struct BufferState::ReplacementStats *rep_stats);
112
118 void printFrame(FrameId frame_id);
119
120
125 virtual void printStats() = 0;
126
132
133 protected:
134
141 virtual RepType _getType() = 0;
142
152
157
161 std::queue<FrameId> free;
162
167 std::uint64_t rep_calls;
168
174
175
181 std::uint64_t new_page_calls;
182
183};
184
185#endif
Definition bm_frame.h:28
Definition bm_replacement.h:29
void _createFree()
Creates a free list for the buffer pool by checking each frame in the buffer pool and checking if it ...
void printFrame(FrameId frame_id)
THIS METHOD IS FOR DEBUGGING ONLY. Prints Frame state relevant to the replacement policy of a given F...
virtual RepType _getType()=0
Returns the type of a given replacement policy. Used to fill struct of replacement statistics.
virtual void freeFrame(FrameId frame_id)
Virtual method that implements any necessary update to replacement policy state following the dealloc...
virtual void printStats()=0
Pure virtual method for printing relevant stats for the specific derived class.
std::uint64_t rep_calls
Definition bm_replacement.h:167
virtual void getRepStats(struct BufferState::ReplacementStats *rep_stats)
Updates the struct of replacement policy statistics within the buffer state struct....
virtual void pin(FrameId frame_id)=0
Pure virtual method that implements any necessary update to replacement policy state following the pi...
std::uint64_t new_page_calls
Definition bm_replacement.h:181
virtual FrameId replace()=0
Pure virtual method that implements core replacement policy functionality in child classes.
double avg_frames_checked
Definition bm_replacement.h:173
virtual ~ReplacementPolicy()
Empty Destructor.
Frame * frame_table
Definition bm_replacement.h:156
void advanceCalls()
Increment new_page_calls by 1. Called in both allocatePage and getPage in BufferManager.
virtual void unpin(FrameId frame_id)=0
Pure virtual method that implements any necessary update to replacement policy state following the un...
std::queue< FrameId > free
Definition bm_replacement.h:161
Definition bufmgr.h:78
std::uint32_t FrameId
Index of each frame in the bufferpool of BufferManager.
Definition swatdb_types.h:44
RepType
Definition swatdb_types.h:167