|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.persistent.AbstractPageFile<P> de.lmu.ifi.dbs.elki.persistent.AbstractStoringPageFile<P> de.lmu.ifi.dbs.elki.persistent.PersistentPageFile<P>
P
- Page typepublic class PersistentPageFile<P extends Page>
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 boolean |
existed
Whether we are initializing from an existing file. |
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. |
private static Logging |
logger
Our logger |
protected Class<P> |
pageclass
The type of pages we use. |
Fields inherited from class de.lmu.ifi.dbs.elki.persistent.AbstractStoringPageFile |
---|
emptyPages, nextPageID, pageSize |
Fields inherited from class de.lmu.ifi.dbs.elki.persistent.AbstractPageFile |
---|
readAccess, writeAccess |
Constructor Summary | |
---|---|
PersistentPageFile(int pageSize,
String fileName,
Class<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. |
boolean |
initialize(PageHeader header)
Initialize the page file with the given header - return "true" if the file already existed. |
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. |
void |
writePage(Integer pageID,
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. |
Methods inherited from class de.lmu.ifi.dbs.elki.persistent.AbstractStoringPageFile |
---|
getInnerStatistics, getNextPageID, getPageSize, setPageID |
Methods inherited from class de.lmu.ifi.dbs.elki.persistent.AbstractPageFile |
---|
getReadOperations, getWriteOperations, resetPageAccess, writePage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logging logger
private static final int EMPTY_PAGE
private static final int FILLED_PAGE
private final RandomAccessFile file
protected PageHeader header
protected final Class<P extends Page> pageclass
private boolean existed
Constructor Detail |
---|
public PersistentPageFile(int pageSize, String fileName, Class<P> pageclass)
pageSize
- the page sizepageclass
- the class of pages to be usedMethod Detail |
---|
public P readPage(int pageID)
pageID
- the id of the page to be returned
public void deletePage(int pageID)
deletePage
in interface PageFile<P extends Page>
deletePage
in class AbstractStoringPageFile<P extends Page>
pageID
- the id of the node to be deletedpublic void writePage(Integer pageID, P page)
page
is not longer
stored in the cache and has to be written to disk.
writePage
in class AbstractPageFile<P extends Page>
page
- the page which has to be written to diskpageID
- Page idpublic void close()
close
in interface PageFile<P extends Page>
close
in class AbstractPageFile<P extends Page>
public void clear()
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 interface PageFile<P extends Page>
setNextPageID
in class AbstractStoringPageFile<P extends Page>
next_page_id
- the id of the next page to be inserted (if there are no
more empty pages to be filled)public boolean initialize(PageHeader header)
AbstractStoringPageFile
initialize
in interface PageFile<P extends Page>
initialize
in class AbstractStoringPageFile<P extends Page>
header
- Header
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |