Class LocalFileAccessor
java.lang.Object
com.illumon.iris.db.util.file.FileHandleAccessor
com.illumon.iris.db.v2.locations.local.LocalFileAccessor
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable,FileAccessor,NamedImplementation
- Direct Known Subclasses:
WritableLocalFileAccessor
Wraps a file, and manages a handle into that file. Supports positional read access only.
TODO: Consider adding a maximum number of retries for each operation that might encounter a ClosedChannelException.
Note: We don't test handle.isOpen(), because it's expected that we will encounter closed handles very rarely.
Note: We could re-open after ClosedByInterruptException for the next call, but it seems better assume this accessor will be used again right away in such cases.
-
Field Summary
Fields inherited from class com.illumon.iris.db.util.file.FileHandleAccessor
file, fileHandleFields inherited from interface com.illumon.iris.db.v2.locations.FileAccessor
NULL_REQUIRED_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionLocalFileAccessor(FileHandleFactory.FileToHandleFunction fileHandleCreator, File file) Make a read-only accessor for a "local" file. -
Method Summary
Modifier and TypeMethodDescriptionfinal com.fishlib.base.log.LogOutputappend(com.fishlib.base.log.LogOutput logOutput) final FilegetFile()Get a name for the implementing class.final intread(ByteBuffer buffer, long position) Fill the supplied buffer with data starting at the supplied offset (position) into this file accessor.final longsize(long unusedRequiredSize) Request an up-to-date size value for the file data space backing this accessor.final StringtoString()Methods inherited from class com.illumon.iris.db.util.file.FileHandleAccessor
refreshFileHandleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.illumon.iris.db.v2.locations.FileAccessor
force, getOffsetView, truncate, write
-
Constructor Details
-
LocalFileAccessor
public LocalFileAccessor(@NotNull FileHandleFactory.FileToHandleFunction fileHandleCreator, @NotNull File file) Make a read-only accessor for a "local" file.- Parameters:
fileHandleCreator- The function used to make file handlesfile- The abstract path name to wrap access to
-
-
Method Details
-
size
public final long size(long unusedRequiredSize) Description copied from interface:FileAccessorRequest an up-to-date size value for the file data space backing this accessor.- Specified by:
sizein interfaceFileAccessor- Parameters:
unusedRequiredSize- 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
-
getFile
-
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 final com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput) - Specified by:
appendin interfacecom.fishlib.base.log.LogOutputAppendable
-
toString
-