Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

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

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.persistent.PageFile<P>
All Implemented Interfaces:
Loggable, CachedFile<P>
Direct Known Subclasses:
MemoryPageFile, PersistentPageFile

public abstract class PageFile<P extends Page<P>>
extends AbstractLoggable
implements CachedFile<P>

Abstract class implementing general methods of a PageFile. A PageFile stores objects that implement the Page inetrface.

Author:
Elke Achtert

Field Summary
protected  Cache<P> cache
          The cache of this file.
protected  Stack<Integer> emptyPages
          A stack holding the empty page ids.
protected  int nextPageID
          The last page ID.
protected  int pageSize
          The size of a page in Bytes.
protected  long readAccess
          The read I/O-Access of this file.
protected  long writeAccess
          The write I/O-Access of this file.
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
protected PageFile()
          Creates a new PageFile.
 
Method Summary
 void clear()
          Clears this PageFile.
 void close()
          Closes this file.
 void deletePage(int pageID)
          Deletes the node with the specified id from this file.
 long getLogicalPageAccess()
          Returns the logical read I/O-Access of this file.
private  Integer getNextEmptyPageID()
          Returns the next empty page id.
 int getNextPageID()
          Returns the next page id.
 long getPhysicalReadAccess()
          Returns the physical read I/O-Access of this file.
 long getPhysicalWriteAccess()
          Returns the physical write I/O-Access of this file.
(package private)  void initCache(int pageSize, int cacheSize, Cache<P> cache)
          Initializes the cache.
 P readPage(int pageID)
          Reads the page with the given id from this file.
 void resetPageAccess()
          Resets the counters for page accesses of this file and flushes the cache.
 void setCacheSize(int cacheSize)
          Sets the maximum size of the cache of this file.
 void setNextPageID(int nextPageID)
          Sets the next page id.
 void setPageID(P page)
          Sets the id of the given page.
 int writePage(P page)
          Writes a page into this file.
 
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
 
Methods inherited from interface de.lmu.ifi.dbs.elki.persistent.CachedFile
objectRemoved
 

Field Detail

cache

protected Cache<P extends Page<P>> cache
The cache of this file.


emptyPages

protected Stack<Integer> emptyPages
A stack holding the empty page ids.


nextPageID

protected int nextPageID
The last page ID.


readAccess

protected long readAccess
The read I/O-Access of this file.


writeAccess

protected long writeAccess
The write I/O-Access of this file.


pageSize

protected int pageSize
The size of a page in Bytes.

Constructor Detail

PageFile

protected PageFile()
Creates a new PageFile.

Method Detail

getPhysicalReadAccess

public final long getPhysicalReadAccess()
Returns the physical read I/O-Access of this file.


getPhysicalWriteAccess

public final long getPhysicalWriteAccess()
Returns the physical write I/O-Access of this file.


getLogicalPageAccess

public final long getLogicalPageAccess()
Returns the logical read I/O-Access of this file.


resetPageAccess

public final void resetPageAccess()
Resets the counters for page accesses of this file and flushes the cache.


setPageID

public void setPageID(P page)
Sets the id of the given page.

Parameters:
page - the page to set the id

writePage

public final int writePage(P page)
Writes a page into this file. The method tests if the page has already an id, otherwise a new id is assigned and returned.

Parameters:
page - the page to be written
Returns:
the id of the page

readPage

public P readPage(int pageID)
Reads the page with the given id from this file.

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.

Parameters:
pageID - the id of the node to be deleted

close

public void close()
Closes this file.


clear

public void clear()
Clears this PageFile.


setCacheSize

public void setCacheSize(int cacheSize)
Sets the maximum size of the cache of this file.

Parameters:
cacheSize -

initCache

void initCache(int pageSize,
               int cacheSize,
               Cache<P> cache)
Initializes the cache.

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

getNextEmptyPageID

private Integer getNextEmptyPageID()
Returns the next empty page id.

Returns:
the next empty page id

getNextPageID

public int getNextPageID()
Returns the next page id.

Returns:
the next page id

setNextPageID

public void setNextPageID(int nextPageID)
Sets the next page id.

Parameters:
nextPageID - the next page id to be set

Release 0.1 (2008-07-10_1838)