|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.persistent.AbstractPageFile<P> de.lmu.ifi.dbs.elki.persistent.LRUCache<P>
P
- Page typepublic class LRUCache<P extends Page>
An LRU cache, based on LinkedHashMap
.
This cache has a fixed maximum number of objects (cacheSize
). If
the cache is full and another object is added, the LRU (least recently used)
object is dropped.
Field Summary | |
---|---|
protected long |
cacheSize
The maximum number of objects in this cache. |
protected long |
cacheSizeBytes
Cache size in bytes. |
protected PageFile<P> |
file
The underlying file of this cache. |
private static Logging |
logger
Our logger |
private LinkedHashMap<Integer,P> |
map
The map holding the objects of this cache. |
Fields inherited from class de.lmu.ifi.dbs.elki.persistent.AbstractPageFile |
---|
readAccess, writeAccess |
Constructor Summary | |
---|---|
LRUCache(long cacheSizeBytes,
PageFile<P> file)
Initializes this cache with the specified parameters. |
Method Summary | |
---|---|
void |
clear()
Clears this cache. |
void |
close()
Closes this file. |
void |
deletePage(int pageID)
Deletes the node with the specified id from this file. |
protected void |
expirePage(P page)
Write page through to disk. |
void |
flush()
Flushes this caches by writing any entry to the underlying file. |
PageFileStatistics |
getInnerStatistics()
Get statistics for the inner page file, if present. |
int |
getNextPageID()
Returns the next page id. |
int |
getPageSize()
Get the page size of this page file. |
boolean |
initialize(PageHeader header)
Initialize the page file with the given header - return "true" if the file already existed. |
P |
readPage(int pageID)
Retrieves a page from the cache. |
void |
setCacheSize(int cacheSize)
Sets the maximum size of this cache. |
void |
setNextPageID(int nextPageID)
Sets the next page id. |
Integer |
setPageID(P page)
Sets the id of the given page. |
String |
toString()
Returns a string representation of this cache. |
void |
writePage(Integer pageID,
P page)
Perform the actual page write operation. |
Methods inherited from class de.lmu.ifi.dbs.elki.persistent.AbstractPageFile |
---|
getReadOperations, getWriteOperations, resetPageAccess, writePage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final Logging logger
protected long cacheSizeBytes
protected long cacheSize
private LinkedHashMap<Integer,P extends Page> map
protected PageFile<P extends Page> file
Constructor Detail |
---|
public LRUCache(long cacheSizeBytes, PageFile<P> file)
cacheSizeBytes
- the maximum number of pages in this cachefile
- the underlying file of this cache, if a page is dropped it is
written to the fileMethod Detail |
---|
public P readPage(int pageID)
pageID
- the id of the page to be returned
public void writePage(Integer pageID, P page)
AbstractPageFile
writePage
in class AbstractPageFile<P extends Page>
pageID
- Page idpage
- Page to writepublic void deletePage(int pageID)
PageFile
pageID
- the id of the node to be deletedprotected void expirePage(P page)
page
- pagepublic Integer setPageID(P page)
PageFile
page
- the page to set the id
public int getNextPageID()
PageFile
public void setNextPageID(int nextPageID)
PageFile
nextPageID
- the next page id to be setpublic int getPageSize()
PageFile
public boolean initialize(PageHeader header)
PageFile
header
- Header
public void close()
PageFile
close
in interface PageFile<P extends Page>
close
in class AbstractPageFile<P extends Page>
public void flush()
public String toString()
toString
in class Object
public void clear()
public void setCacheSize(int cacheSize)
cacheSize
- the cache size to be setpublic PageFileStatistics getInnerStatistics()
PageFileStatistics
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |