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, fileHandle
Fields 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 void
force()
Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously.final String
Get a name for the implementing class.final void
truncate
(long size) Truncate the file data space backing this accessor to the supplied size.final 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 class com.illumon.iris.db.v2.locations.local.LocalFileAccessor
append, getFile, read, size, toString
Methods inherited from class com.illumon.iris.db.util.file.FileHandleAccessor
refreshFileHandle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:FileAccessor
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
public final void truncate(long size) Description copied from interface:FileAccessor
Truncate 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:FileAccessor
Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously. -
getImplementationName
Description copied from interface:NamedImplementation
Get a name for the implementing class. Useful for abstract classes that implement
LogOutputAppendable
or overridetoString
.The default implementation is correct, but not suitable for high-frequency usage.
- Specified by:
getImplementationName
in interfaceNamedImplementation
- Overrides:
getImplementationName
in classLocalFileAccessor
- Returns:
- A name for the implementing class
-