P
- Page typepublic class PersistentPageFile<P extends ExternalizablePage> extends AbstractStoringPageFile<P>
Page
interface. For convenience each page is represented by a
single file. All pages are stored in a specified directory.Modifier and Type | Field and Description |
---|---|
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 |
LOG
Our logger
|
protected Class<P> |
pageclass
The type of pages we use.
|
emptyPages, nextPageID, pageSize
Constructor and Description |
---|
PersistentPageFile(int pageSize,
String fileName,
Class<P> pageclass)
Creates a new PersistentPageFile from an existing file.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected Logging |
getLogger()
Get the class logger.
|
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(int 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. |
getNextPageID, getPageSize, logStatistics, setPageID
countRead, countWrite, writePage
private static final Logging LOG
private static final int EMPTY_PAGE
private static final int FILLED_PAGE
private final RandomAccessFile file
protected PageHeader header
protected final Class<P extends ExternalizablePage> pageclass
private boolean existed
public P readPage(int pageID)
pageID
- the id of the page to be returnedpublic void deletePage(int pageID)
deletePage
in interface PageFile<P extends ExternalizablePage>
deletePage
in class AbstractStoringPageFile<P extends ExternalizablePage>
pageID
- the id of the node to be deletedpublic void writePage(int pageID, P page)
page
is not longer
stored in the cache and has to be written to disk.writePage
in class AbstractPageFile<P extends ExternalizablePage>
page
- the page which has to be written to diskpageID
- Page idpublic void close()
close
in interface PageFile<P extends ExternalizablePage>
close
in class AbstractPageFile<P extends ExternalizablePage>
public void clear()
private P byteArrayToPage(byte[] array)
array
- the byte array from which the object should be reconstructedprivate byte[] pageToByteArray(P page)
page
- the object to be serializedpublic RandomAccessFile getFile()
public PageHeader getHeader()
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 ExternalizablePage>
setNextPageID
in class AbstractStoringPageFile<P extends ExternalizablePage>
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 ExternalizablePage>
initialize
in class AbstractStoringPageFile<P extends ExternalizablePage>
header
- Headerprotected Logging getLogger()
AbstractPageFile
getLogger
in class AbstractPageFile<P extends ExternalizablePage>
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.