de.lmu.ifi.dbs.elki.persistent
Class MemoryPageFile<P extends Page<P>>
java.lang.Object
de.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.persistent.PageFile<P>
de.lmu.ifi.dbs.elki.persistent.MemoryPageFile<P>
- All Implemented Interfaces:
- Loggable, CachedFile<P>
public class MemoryPageFile<P extends Page<P>>
- extends PageFile<P>
A memory based implementation of a PageFile that simulates I/O-access.
Implemented as a Map with keys representing the ids of the saved pages.
- Author:
- Elke Achtert
Constructor Summary |
MemoryPageFile(int pageSize,
int cacheSize,
Cache<P> cache)
Creates a new MemoryPageFile that is supported by a cache with the
specified parameters. |
Method Summary |
void |
clear()
Clears this PageFile. |
void |
deletePage(int pageID)
Deletes the node with the specified id from this file. |
void |
objectRemoved(P page)
This method is called by the cache if the page is not longer
stored in the cache and has to be written to disk. |
P |
readPage(int pageID)
Reads the page with the given id from this file. |
Methods inherited from class de.lmu.ifi.dbs.elki.persistent.PageFile |
close, getLogicalPageAccess, getNextPageID, getPhysicalReadAccess, getPhysicalWriteAccess, initCache, resetPageAccess, setCacheSize, setNextPageID, setPageID, writePage |
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
file
private final Map<Integer,P extends Page<P>> file
- Holds the pages.
MemoryPageFile
public MemoryPageFile(int pageSize,
int cacheSize,
Cache<P> cache)
- Creates a new MemoryPageFile that is supported by a cache with the
specified parameters.
- Parameters:
pageSize
- the size of a page in BytescacheSize
- the size of the cache in Bytecache
- the class of the cache to be used
objectRemoved
public void objectRemoved(P page)
- Description copied from interface:
CachedFile
- This method is called by the cache if the
page
is not longer
stored in the cache and has to be written to disk.
- Parameters:
page
- the page which has to be written to disk- See Also:
CachedFile.objectRemoved(Page)
readPage
public P readPage(int pageID)
- Reads the page with the given id from this file.
- Overrides:
readPage
in class PageFile<P extends Page<P>>
- Parameters:
pageID
- the id of the page to be returned
- Returns:
- the page with the given pageId
deletePage
public void deletePage(int pageID)
- Deletes the node with the specified id from this file.
- Overrides:
deletePage
in class PageFile<P extends Page<P>>
- Parameters:
pageID
- the id of the node to be deleted
clear
public void clear()
- Clears this PageFile.
- Overrides:
clear
in class PageFile<P extends Page<P>>