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
public class WritableLocalFileAccessor extends LocalFileAccessor
Wraps a file, and manages a handle into that file. Supports positional read and write access.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description WritableLocalFileAccessor(FileHandleFactory.FileToHandleFunction fileHandleCreator, File file)
-
Method Summary
Modifier and Type Method Description void
force()
Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously.String
getImplementationName()
Get a name for the implementing class.void
truncate(long size)
Truncate the file data space backing this accessor to the supplied size.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
-
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
-