public class BufferManager
extends java.lang.Object
Constructor and Description |
---|
BufferManager(int numPages)
Create a new buffer manager given the number of pages the
buffer manager should hold.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsPage(PageIdentifier pageid)
Is the page specified by the page id in the buffer pool
or not?
|
protected int |
getIndex(PageIdentifier pageid)
Returns the index of a page in the pool given its identifier.
|
int |
getNumberOfPages()
The number of pages stored in this buffer manager.
|
Page |
getPage(PageIdentifier pageid)
Returns a page given a page id.
|
protected int |
indexToEvict()
Identify the page to be evicted from the buffer pool to make
room.
|
void |
invalidate(java.lang.String fn)
Invalidate all buffer pool entries for a specific file.
|
protected boolean |
isFull()
Is the buffer manager full or not?
|
Page |
putPage(Page page)
Wrapper for putting a page in the buffer pool, assuming the
page is dirty.
|
Page |
putPage(Page page,
boolean dirty)
Puts a page in the buffer pool.
|
void |
touchPage(Page page)
Touches a page in the buffer pool (if it exists) making it dirty
and setting its timestamp.
|
void |
touchPage(PageIdentifier pageid)
Touches the page corresponding to the pageid making it dirty
and moving it to the back of the replacement queue.
|
public BufferManager(int numPages)
numPages
- this buffer manager's number of pagespublic int getNumberOfPages()
public boolean containsPage(PageIdentifier pageid)
pageid
- the id of the page searched for.trueif the page is in the buffer pool
falseotherwise.
public Page getPage(PageIdentifier pageid)
pageid
- the id of the page to be returnedprotected int getIndex(PageIdentifier pageid)
public void touchPage(PageIdentifier pageid)
pageid
- the pageid of the page to be touched.public void touchPage(Page page)
page
- the page to be touched.public Page putPage(Page page)
page
- the page to be inserted.public Page putPage(Page page, boolean dirty)
page
- the page to be inserted into the buffer pool.dirty
- is this page dirty or not?protected boolean isFull()
trueif the buffer manager is full
falseotherwise.
protected int indexToEvict()
public void invalidate(java.lang.String fn)
fn
- the filename.