Package com.illumon.iris.db.v2.locations
Class LazyFileAccessor
java.lang.Object
com.illumon.iris.db.v2.locations.LazyFileAccessor
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable,FileAccessor,NamedImplementation
Lazily-initialized FileAccessor implementation.
Defers initialization costs, e.g. file handle allocation or size-buffer reading whenever possible.
-
Field Summary
Fields 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(@NotNull 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.final intread(@NotNull ByteBuffer buffer, long position) Fill the supplied buffer with data starting at the supplied offset (position) into this file accessor.final 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(@NotNull 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.
-
Constructor Details
-
LazyFileAccessor
-
-
Method Details
-
size
public final 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
-
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 override
Object.toString().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 @NotNull com.fishlib.base.log.LogOutput logOutput) - Specified by:
appendin interfacecom.fishlib.base.log.LogOutputAppendable
-
toString
-