public interface PageSwapper
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close and release all resources associated with the file underlying this PageSwapper.
|
void |
closeAndDelete()
Close and release all resources associated with the file underlying this PageSwapper, and then delete that file.
|
void |
evicted(long pageId,
Page page)
Notification that a page has been evicted, used to clean up state in structures
outside the page table.
|
File |
file()
Get the file that this PageSwapper represents.
|
void |
force()
Forces all writes done by this PageSwapper to the underlying storage device, such that the writes are durable
when this call returns.
|
long |
getLastPageId()
Get the filePageId of the last page in the concrete file.
|
long |
read(long filePageId,
Page page)
Read the page with the given filePageId, from the concrete file on the
file system, into the given page.
|
long |
read(long startFilePageId,
Page[] pages,
int arrayOffset,
int length)
Read pages from the file into the given pages, starting from the given startFilePageId.
|
void |
truncate()
Truncate the file represented by this PageSwapper, so the size of the file is zero and
getLastPageId() returns -1. |
long |
write(long filePageId,
Page page)
Write the contents of the given page, to the concrete file on the file
system, at the located indicated by the given filePageId.
|
long |
write(long startFilePageId,
Page[] pages,
int arrayOffset,
int length)
Write the contents of the given pages, to the concrete file on the file system,
starting at the location of the given startFilePageId.
|
long read(long filePageId,
Page page)
throws IOException
Returns the number of bytes read in from the file. May be zero if the requested page was beyond the end of the file. If less than the file page size, then the rest of the page will contain zeros.
Note: It is possible for the channel to be asynchronously closed while this operation is taking place. For instance, if the current thread is interrupted. If this happens, then the implementation must reopen the channel and the operation must be retried.
IOExceptionlong read(long startFilePageId,
Page[] pages,
int arrayOffset,
int length)
throws IOException
Returns the number of bytes read in from the file. May be zero if the requested startFilePageId was beyond the end of the file. If the file does not have enough data to fill up all the buffer space represented by the pages, then the remaining buffer space will be filled with zero bytes.
The contents of the pages should be considered to be garbage if the operation throws an exception, since the constituent reads can be reordered, and no zeroing will take place.
Note: It is possible for the channel to be asynchronously closed while this operation is taking place. For instance, if the current thread is interrupted. If this happens, then the implementation must reopen the channel and the operation must be retried.
IOExceptionlong write(long filePageId,
Page page)
throws IOException
Returns the number of bytes written to the file.
Note: It is possible for the channel to be asynchronously closed while this operation is taking place. For instance, if the current thread is interrupted. If this happens, then implementation must reopen the channel and the operation must be retried.
IOExceptionlong write(long startFilePageId,
Page[] pages,
int arrayOffset,
int length)
throws IOException
If an exception is thrown, then some of the data may have been written, and some might not. The writes may reorder and tear, so no guarantee can be made about what has been written and what has not, if an exception is thrown. Therefor, the entire write operation should be retried, in the case of failure, or the data should be rewritten through other means.
Returns the number of bytes written to the file.
Note: It is possible for the channel to be asynchronously closed while this operation is taking place. For instance, if the current thread is interrupted. If this happens, then implementation must reopen the channel and the operation must be retried.
IOExceptionvoid evicted(long pageId,
Page page)
File file()
void close()
throws IOException
IOExceptionvoid closeAndDelete()
throws IOException
IOException - If an IOException occurs during either the closing or the deleting of the file. This
may leave the file on the file system.void force()
throws IOException
This method has no effect if the PageSwapperFactory.syncDevice() method forces the writes for all
non-closed PageSwappers created through the given PageSwapperFactory.
The PageCache.flushAndForce() method will first call force on the PageSwappers for all
mapped files, then call syncDevice on the PageSwapperFactory. This way, the writes are always made
durable regardless of which method that does the forcing.
IOExceptionlong getLastPageId()
throws IOException
IOExceptionvoid truncate()
throws IOException
getLastPageId() returns -1.
Truncation may occur concurrently with writes, in which case both operations will appear to be atomic, such that either the write happens before the truncation and is lost, or the file is truncated and the write then extends the file with any zero padding and the written data.
IOExceptionCopyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.