|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.lmu.ifi.dbs.elki.persistent.PageFile<P>
de.lmu.ifi.dbs.elki.persistent.PersistentPageFile<P>
P
- Page typepublic class PersistentPageFile<P extends Page<P>>
A PersistentPageFile 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.
Field Summary | |
---|---|
private static int |
EMPTY_PAGE
Indicates an empty page. |
private RandomAccessFile |
file
The file storing the pages. |
private static int |
FILLED_PAGE
Indicates a filled page. |
protected PageHeader |
header
The header of this page file. |
protected Class<? extends P> |
pageclass
The type of pages we use. |
Fields inherited from class de.lmu.ifi.dbs.elki.persistent.PageFile |
---|
cache, emptyPages, nextPageID, pageSize, readAccess, writeAccess |
Constructor Summary | |
---|---|
PersistentPageFile(PageHeader header,
long cacheSize,
Cache<P> cache,
String fileName,
Class<? extends P> pageclass)
Creates a new PersistentPageFile 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. |
RandomAccessFile |
getFile()
|
PageHeader |
getHeader()
Get the header of this persistent page file. |
void |
increaseReadAccess()
Increases the readAccess counter by one. |
void |
increaseWriteAccess()
Increases the writeAccess counter by one. |
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. |
void |
setNextPageID(int next_page_id)
Set the next page id to the given value. |
Methods inherited from class de.lmu.ifi.dbs.elki.persistent.PageFile |
---|
getLogicalPageAccess, getNextPageID, getPhysicalReadAccess, getPhysicalWriteAccess, initCache, resetPageAccess, setCacheSize, setPageID, writePage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int EMPTY_PAGE
private static final int FILLED_PAGE
private final RandomAccessFile file
protected final PageHeader header
protected final Class<? extends P extends Page<P>> pageclass
Constructor Detail |
---|
public PersistentPageFile(PageHeader header, long cacheSize, Cache<P> cache, String fileName, Class<? extends P> pageclass)
header
- the header of this filefileName
- the name of the filecacheSize
- the size of the cache in Bytecache
- the class of the cache to be usedpageclass
- the class of pages to be usedMethod Detail |
---|
public P readPage(int pageID)
readPage
in class PageFile<P extends Page<P>>
pageID
- the id of the page to be returned
public void deletePage(int pageID)
deletePage
in class PageFile<P extends Page<P>>
pageID
- the id of the node to be deletedpublic void objectRemoved(P page)
page
is not longer
stored in the cache and has to be written to disk.
page
- the page which has to be written to diskpublic void close()
close
in class PageFile<P extends Page<P>>
public void clear()
clear
in class PageFile<P extends Page<P>>
private P byteArrayToPage(byte[] array)
array
- the byte array from which the object should be reconstructed
private byte[] pageToByteArray(P page)
page
- the object to be serialized
public RandomAccessFile getFile()
public PageHeader getHeader()
public void increaseReadAccess()
readAccess
counter by one.
public void increaseWriteAccess()
writeAccess
counter by one.
public void setNextPageID(int next_page_id)
emptyPages
are smaller than
next_page_id
, they are removed from this file's observation
stack.
setNextPageID
in class PageFile<P extends Page<P>>
next_page_id
- the id of the next page to be inserted (if there are no
more empty pages to be filled)
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |