Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.persistent
Class OnDiskArrayPageFile<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.OnDiskArrayPageFile<P>
Type Parameters:
P - Page type
All Implemented Interfaces:
CachedFile<P>

public class OnDiskArrayPageFile<P extends Page<P>>
extends PageFile<P>

A OnDiskArrayPageFile stores objects persistently that implement the Page interface. For convenience each page is represented by a single file. All pages are stored in a specified directory.

Author:
Elke Achtert

Field Summary
private static int EMPTY_PAGE
          Indicates an empty page.
private  OnDiskArray file
          The file storing the pages.
private static int FILLED_PAGE
          Indicates a filled page.
protected  PageHeader header
          The header of this page file.
 
Fields inherited from class de.lmu.ifi.dbs.elki.persistent.PageFile
cache, emptyPages, nextPageID, pageSize, readAccess, writeAccess
 
Constructor Summary
OnDiskArrayPageFile(PageHeader header, int cacheSize, Cache<P> cache, String fileName)
          Creates a new OnDiskArrayPageFile from an existing file.
 
Method Summary
private  P byteArrayToPage(byte[] array)
          Reconstruct a serialized object from the specified byte array.
 void clear()
          Clears this PageFile.
 void close()
          Closes this file.
 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.
private  byte[] pageToByteArray(P page)
          Serializes an object into a byte array.
 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
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

EMPTY_PAGE

private static final int EMPTY_PAGE
Indicates an empty page.

See Also:
Constant Field Values

FILLED_PAGE

private static final int FILLED_PAGE
Indicates a filled page.

See Also:
Constant Field Values

file

private final OnDiskArray file
The file storing the pages.


header

protected final PageHeader header
The header of this page file.

Constructor Detail

OnDiskArrayPageFile

public OnDiskArrayPageFile(PageHeader header,
                           int cacheSize,
                           Cache<P> cache,
                           String fileName)
Creates a new OnDiskArrayPageFile from an existing file.

Parameters:
header - the header of this file
fileName - the name of the file
cacheSize - the size of the cache in Byte
cache - the class of the cache to be used
Method Detail

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

objectRemoved

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

Parameters:
page - the page which has to be written to disk

close

public void close()
Closes this file.

Overrides:
close in class PageFile<P extends Page<P>>

clear

public void clear()
Clears this PageFile.

Overrides:
clear in class PageFile<P extends Page<P>>

byteArrayToPage

private P byteArrayToPage(byte[] array)
Reconstruct a serialized object from the specified byte array.

Parameters:
array - the byte array from which the object should be reconstructed
Returns:
a serialized object from the specified byte array

pageToByteArray

private byte[] pageToByteArray(P page)
Serializes an object into a byte array.

Parameters:
page - the object to be serialized
Returns:
the byte array

Release 0.3 (2010-03-31_1612)