Class MappedPageArray
java.lang.Object
org.cojen.tupl.io.PageArray
org.cojen.tupl.io.MappedPageArray
- All Implemented Interfaces:
Closeable
,AutoCloseable
,CauseCloseable
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
long
copyPage
(long srcIndex, long dstIndex) long
copyPageFromAddress
(long srcAddr, long dstIndex) long
directPageAddress
(long index) void
expandPageCount
(long count) Attempt to expand the total count of pages.static Supplier
<MappedPageArray> factory
(int pageSize, long pageCount, File file, EnumSet<OpenOption> options) final boolean
isClosed()
boolean
isEmpty()
final boolean
final boolean
static boolean
long
Returns the total count of pages in the array, or Long.MAX_VALUE if not applicable.long
Return maximum allowed page count, or -1 if not applicable.void
readPage
(long index, long dstAddr, int offset, int length) void
sync
(boolean metadata) Durably flushes all writes to the underlying device.void
syncPage
(long index) Durably flushes the page at the given index, but implementation might flush more pages.void
truncatePageCount
(long count) Attempt to truncate the total count of pages.void
writePage
(long index, long srcAddr, int offset) Writes a page, which is lazily flushed.Methods inherited from class org.cojen.tupl.io.PageArray
close, directPageSize, dirtyPage, evictPage, isDirectIO, pageSize, readPage, writePage
-
Method Details
-
isSupported
public static boolean isSupported() -
factory
public static Supplier<MappedPageArray> factory(int pageSize, long pageCount, File file, EnumSet<OpenOption> options) - Parameters:
file
- file to store pages, or null if anonymousoptions
- can be null if none- Throws:
UnsupportedOperationException
- if not running on a 64-bit platform
-
isFullyMapped
public final boolean isFullyMapped()- Overrides:
isFullyMapped
in classPageArray
-
isReadOnly
public final boolean isReadOnly()- Specified by:
isReadOnly
in classPageArray
-
isEmpty
-
pageCount
-
truncatePageCount
public void truncatePageCount(long count) Description copied from class:PageArray
Attempt to truncate the total count of pages. Array implementation might not support truncating the page count, in which case this method does nothing.- Specified by:
truncatePageCount
in classPageArray
-
expandPageCount
public void expandPageCount(long count) Description copied from class:PageArray
Attempt to expand the total count of pages. Array implementation might not support expanding the page count, in which case this method does nothing.- Specified by:
expandPageCount
in classPageArray
-
pageCountLimit
public long pageCountLimit()Description copied from class:PageArray
Return maximum allowed page count, or -1 if not applicable.- Overrides:
pageCountLimit
in classPageArray
-
readPage
- Specified by:
readPage
in classPageArray
- Parameters:
index
- zero-based page index to readdstAddr
- receives read dataoffset
- offset into data buffer- Throws:
IOException
- if index is greater than or equal to page count
-
writePage
Description copied from class:PageArray
Writes a page, which is lazily flushed. The array grows automatically if the index is greater than or equal to the current page count. If array supports caching, page must be immediately copied into it.- Specified by:
writePage
in classPageArray
- Parameters:
index
- zero-based page index to writesrcAddr
- data to writeoffset
- offset into data buffer- Throws:
IOException
-
directPageAddress
- Overrides:
directPageAddress
in classPageArray
- Throws:
IOException
-
copyPage
- Overrides:
copyPage
in classPageArray
- Returns:
- direct pointer to destination
- Throws:
IOException
-
copyPageFromAddress
- Overrides:
copyPageFromAddress
in classPageArray
- Returns:
- direct pointer to destination
- Throws:
IOException
-
sync
Description copied from class:PageArray
Durably flushes all writes to the underlying device.- Specified by:
sync
in classPageArray
- Parameters:
metadata
- pass true to flush all file metadata- Throws:
IOException
-
syncPage
Description copied from class:PageArray
Durably flushes the page at the given index, but implementation might flush more pages. File metadata is not flushed.- Overrides:
syncPage
in classPageArray
- Throws:
IOException
-
close
- Specified by:
close
in interfaceCauseCloseable
- Specified by:
close
in classPageArray
- Parameters:
cause
- null if close is not caused by a failure- Throws:
IOException
-
isClosed
-