neustore.base
Class LRUBuffer
java.lang.Object
neustore.base.DBBuffer
neustore.base.LRUBuffer
public class LRUBuffer
- extends DBBuffer
The LRU buffer.
- Author:
- Donghui Zhang <donghui@ccs.neu.edu>
Field Summary |
protected java.util.Vector<neustore.base.DBBuffer.DBBufferStoredElement> |
buffer
|
protected java.util.HashMap<neustore.base.DBBuffer.DBBufferHashKey,neustore.base.DBBuffer.DBBufferStoredElement> |
hash
|
Constructor Summary |
LRUBuffer(int bufferSize,
int pageSize)
|
Method Summary |
protected void |
add(neustore.base.DBBuffer.DBBufferStoredElement stored)
Adds a page to the buffer. |
protected neustore.base.DBBuffer.DBBufferStoredElement |
find(java.io.RandomAccessFile file,
int pageID)
Finds a page in buffer. |
protected void |
flush(java.io.RandomAccessFile file)
Flushes the buffer pages of a given file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
buffer
protected java.util.Vector<neustore.base.DBBuffer.DBBufferStoredElement> buffer
hash
protected java.util.HashMap<neustore.base.DBBuffer.DBBufferHashKey,neustore.base.DBBuffer.DBBufferStoredElement> hash
LRUBuffer
public LRUBuffer(int bufferSize,
int pageSize)
find
protected neustore.base.DBBuffer.DBBufferStoredElement find(java.io.RandomAccessFile file,
int pageID)
- Finds a page in buffer.
If found, move to the beginning of buffer.
Note: do not increase bufferReadIO.
- Specified by:
find
in class DBBuffer
- Parameters:
pageID
- the page IDfile
- the file
- Returns:
- an instance of DBBufferStoredElement if found; nullotherwise.
add
protected void add(neustore.base.DBBuffer.DBBufferStoredElement stored)
throws java.io.IOException
- Adds a page to the buffer.
Note: do not increase bufferReadIO.
The element should not exist in the buffer already.
- Specified by:
add
in class DBBuffer
- Parameters:
stored
- the stored element
- Throws:
java.io.IOException
flush
protected void flush(java.io.RandomAccessFile file)
throws java.io.IOException
- Flushes the buffer pages of a given file.
Makes the buffer empty, while saving modified pages to disk.
- Specified by:
flush
in class DBBuffer
- Parameters:
file
- the file
- Throws:
java.io.IOException