Class WritableLocalFileAccessor
java.lang.Object
com.illumon.iris.db.util.file.FileHandleAccessor
com.illumon.iris.db.v2.locations.local.LocalFileAccessor
com.illumon.iris.db.v2.locations.local.WritableLocalFileAccessor
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable,FileAccessor,NamedImplementation
Wraps a file, and manages a handle into that file. Supports positional read and write access.
-
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
ConstructorsConstructorDescriptionWritableLocalFileAccessor(FileHandleFactory.FileToHandleFunction fileHandleCreator, File file) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidforce()Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously.final StringGet a name for the implementing class.final voidtruncate(long size) Truncate the file data space backing this accessor to the supplied size.final 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.Methods inherited from class com.illumon.iris.db.v2.locations.local.LocalFileAccessor
append, getFile, read, size, toStringMethods 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
getOffsetView
-
Constructor Details
-
WritableLocalFileAccessor
public WritableLocalFileAccessor(@NotNull FileHandleFactory.FileToHandleFunction fileHandleCreator, @NotNull File file)
-
-
Method Details
-
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.- 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 final void truncate(long size) Description copied from interface:FileAccessorTruncate the file data space backing this accessor to the supplied size.- Parameters:
size- The new size
-
force
public final void force()Description copied from interface:FileAccessorMake sure any previous writes to the underlying file through this file accessor are persisted, synchronously. -
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- Overrides:
getImplementationNamein classLocalFileAccessor- Returns:
- A name for the implementing class
-