wisc_db
Main Page
Namespaces
Classes
Files
File List
home
newhall
public
cs44
wiscdb
src
buffer.h
1
9
#pragma once
10
11
#include "include/file.h"
12
#include "bufferHashTable.h"
13
14
namespace
wiscdb
{
15
19
class
BufferManager
;
20
25
class
Frame
{
26
27
friend
class
BufferManager
;
28
29
private
:
33
File
* file;
34
38
PageId
pageNo;
39
43
FrameId
frameNo;
44
48
int
pinCnt;
49
53
bool
dirty;
54
58
bool
valid;
59
63
bool
refbit;
64
68
void
reset();
69
78
void
load(
File
* filePtr,
PageId
pageNum);
79
80
void
print();
81
85
Frame
();
86
};
87
88
92
struct
BufferStats
93
{
97
int
accesses
;
98
102
int
diskreads
;
103
107
int
diskwrites
;
108
112
void
clear
()
113
{
114
accesses = diskreads = diskwrites = 0;
115
}
116
120
BufferStats
()
121
{
122
clear();
123
}
124
};
125
126
131
class
BufferManager
132
{
133
private
:
138
FrameId
clockHand;
139
143
std::uint32_t numFrames;
144
148
BufferHashTable
*hashTable;
149
154
Frame
*frameTable;
155
159
BufferStats
bufferStats;
160
164
void
advanceClock();
165
175
void
allocateFrame(
FrameId
& frame);
176
177
public
:
182
Page
*
bufPool
;
183
187
BufferManager
(std::uint32_t bufs);
188
192
~
BufferManager
();
193
206
void
readPage(
File
* file,
const
PageId
PageNo,
Page
*& page);
207
217
void
unPinPage(
File
* file,
const
PageId
PageNo,
const
bool
dirty);
218
229
void
allocatePage(
File
* file,
PageId
&PageNo,
Page
*& page);
230
243
void
flushFile(
const
File
* file);
244
253
void
disposePage(
File
* file,
const
PageId
PageNo);
254
258
void
printSelf();
259
263
BufferStats
&
getBufferStats
()
264
{
265
return
bufferStats;
266
}
267
271
void
clearBufferStats
()
272
{
273
bufferStats.
clear
();
274
}
275
};
276
277
}
wiscdb::BufferStats::diskwrites
int diskwrites
Definition:
buffer.h:107
wiscdb::Page
Class which represents a fixed-size database page containing records.
Definition:
page.h:110
wiscdb
Definition:
buffer.h:14
wiscdb::Frame
Maintains information about one buffer pool frame. One frame corresponds to one page on disk...
Definition:
buffer.h:25
wiscdb::BufferManager::getBufferStats
BufferStats & getBufferStats()
Definition:
buffer.h:263
wiscdb::BufferStats::accesses
int accesses
Definition:
buffer.h:97
wiscdb::BufferStats::clear
void clear()
Definition:
buffer.h:112
wiscdb::BufferHashTable
Definition:
bufferHashTable.h:44
wiscdb::BufferStats
Class to maintain statistics of buffer usage.
Definition:
buffer.h:92
wiscdb::PageId
std::uint32_t PageId
Identifier for a page in a file.
Definition:
types.h:15
wiscdb::FrameId
std::uint32_t FrameId
Identifier for a frame in buffer pool.
Definition:
types.h:25
wiscdb::BufferManager::bufPool
Page * bufPool
Definition:
buffer.h:182
wiscdb::File
Represents a file in the filesystem containing pages.
Definition:
file.h:71
wiscdb::BufferStats::diskreads
int diskreads
Definition:
buffer.h:102
wiscdb::BufferManager
The central class which manages the buffer pool including frame allocation and deallocation to pages ...
Definition:
buffer.h:131
wiscdb::BufferManager::clearBufferStats
void clearBufferStats()
Definition:
buffer.h:271
wiscdb::BufferStats::BufferStats
BufferStats()
Definition:
buffer.h:120
Generated by
1.8.11