Package com.illumon.iris.db.v2.locations
Class OffsetFileAccessor<UFAT extends FileAccessor>
java.lang.Object
com.illumon.iris.db.v2.locations.OffsetFileAccessor<UFAT>
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable,FileAccessor,NamedImplementation
Wrap an underlying FileAccessor, providing an offset view into the underlying accessor's data.
The offset view will be writable if and only if the underlying FileAccessor is writable.
-
Field Summary
FieldsFields inherited from interface com.illumon.iris.db.v2.locations.FileAccessor
NULL_REQUIRED_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.fishlib.base.log.LogOutputappend(com.fishlib.base.log.LogOutput logOutput) voidforce()Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously.Get a name for the implementing class.getOffsetView(long startOffset) Get an offset view into this FileAccessor.intread(ByteBuffer buffer, long position) Fill the supplied buffer with data starting at the supplied offset (position) into this file accessor.longsize(long requiredSize) Request an up-to-date size value for the file data space backing this accessor.toString()voidtruncate(long size) Truncate the file data space backing this accessor to the supplied size.intwrite(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.
-
Field Details
-
underlyingFileAccessor
-
startOffset
protected final long startOffset
-
-
Constructor Details
-
OffsetFileAccessor
- Parameters:
underlyingFileAccessor- The file accessor to wrapstartOffset- The offset into the underlying file accessor's data
-
-
Method Details
-
size
public long size(long requiredSize) Description copied from interface:FileAccessorRequest an up-to-date size value for the file data space backing this accessor.- Specified by:
sizein interfaceFileAccessor- 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
Description copied from interface:FileAccessorFill 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.- Specified by:
readin interfaceFileAccessor- 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
Description copied from interface:FileAccessorWrite the supplied buffer (from buffer.position(), inclusive, to buffer.limit(), exclusive), starting at the supplied offset (position) into this file accessor.- Specified by:
writein interfaceFileAccessor- 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
public void truncate(long size) Description copied from interface:FileAccessorTruncate the file data space backing this accessor to the supplied size.- Specified by:
truncatein interfaceFileAccessor- Parameters:
size- The new size
-
force
public void force()Description copied from interface:FileAccessorMake sure any previous writes to the underlying file through this file accessor are persisted, synchronously.- Specified by:
forcein interfaceFileAccessor
-
getOffsetView
Description copied from interface:FileAccessorGet an offset view into this FileAccessor.- Specified by:
getOffsetViewin interfaceFileAccessor- Parameters:
startOffset- The offset- Returns:
- The new offset view accessor
-
getImplementationName
Description copied from interface:NamedImplementationGet a name for the implementing class. Useful for abstract classes that implement
LogOutputAppendableor overridetoString.The default implementation is correct, but not suitable for high-frequency usage.
- Specified by:
getImplementationNamein interfaceNamedImplementation- Returns:
- A name for the implementing class
-
append
public com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput) - Specified by:
appendin interfacecom.fishlib.base.log.LogOutputAppendable
-
toString
-