Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.persistent
Class MemoryPageFile<P extends Page<P>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.persistent.PageFile<P>
      extended by de.lmu.ifi.dbs.elki.persistent.MemoryPageFile<P>
Type Parameters:
P - Page type
All Implemented Interfaces:
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

Field Summary
private  Map<Integer,P> file
          Holds the pages.
 
Fields inherited from class de.lmu.ifi.dbs.elki.persistent.PageFile
cache, emptyPages, nextPageID, pageSize, readAccess, writeAccess
 
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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

private final Map<Integer,P extends Page<P>> file
Holds the pages.

Constructor Detail

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 Bytes
cacheSize - the size of the cache in Byte
cache - the class of the cache to be used
Method Detail

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

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>>

Release 0.2 (2009-07-06_1820)