Package com.illumon.iris.db.v2.locations
Interface FileAccessor
- All Superinterfaces:
com.fishlib.base.log.LogOutputAppendable
,NamedImplementation
- All Known Implementing Classes:
LazyFileAccessor
,LocalFileAccessor
,OffsetFileAccessor
,WritableLocalFileAccessor
Interface to abstract-away local or remote file access.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault void
force()
Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously.default FileAccessor
getOffsetView
(long startOffset) Get an offset view into this FileAccessor.int
read
(ByteBuffer buffer, long position) Fill the supplied buffer with data starting at the supplied offset (position) into this file accessor.long
size
(long requiredSize) Request an up-to-date size value for the file data space backing this accessor.default void
truncate
(long size) Truncate the file data space backing this accessor to the supplied size.default int
write
(ByteBuffer buffer, long position) Write the supplied buffer (from buffer.position(), inclusive, to buffer.limit(), exclusive), starting at the supplied offset (position) into this file accessor.Methods inherited from interface com.fishlib.base.log.LogOutputAppendable
append
Methods inherited from interface com.illumon.util.type.NamedImplementation
getImplementationName
-
Field Details
-
NULL_REQUIRED_SIZE
static final long NULL_REQUIRED_SIZEThe "null" size hint.- See Also:
-
-
Method Details
-
size
long size(long requiredSize) Request an up-to-date size value for the file data space backing this accessor.- Parameters:
requiredSize
- Hint about the minimum size the caller would like as a result- Returns:
- The size of the file data space backing this accessor
-
read
Fill the supplied buffer with data starting at the supplied offset (position) into this file accessor. A successful invocation will fill the buffer from buffer.position(), inclusive, to at least buffer.limit(), exclusive, possibly up to buffer.capacity(), exclusive.- Parameters:
buffer
- A buffer with state appropriate for a call to FileChannel.read()position
- The start position in this file accessor's data space to read from- Returns:
- The number of bytes read, or -1 on error
-
write
Write the supplied buffer (from buffer.position(), inclusive, to buffer.limit(), exclusive), starting at the supplied offset (position) into this file accessor.- Parameters:
buffer
- A buffer with state appropriate for a call to FileChannel.write()position
- The start position in this file accessor's data space to write to- Returns:
- The number of bytes written, or -1 on error
-
truncate
default void truncate(long size) Truncate the file data space backing this accessor to the supplied size.- Parameters:
size
- The new size
-
force
default void force()Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously. -
getOffsetView
Get an offset view into this FileAccessor.- Parameters:
startOffset
- The offset- Returns:
- The new offset view accessor
-