public static class WriteCache.FileChannelWriteCache extends WriteCache
WriteCache
implementation suitable for an append-only file such
as the WORMStrategy
or the output file of the
IndexSegmentBuilder
.WriteCache.FileChannelScatteredWriteCache, WriteCache.FileChannelWriteCache, WriteCache.HAPackage, WriteCache.ReadCache, WriteCache.RecordMetadata
Modifier and Type | Field and Description |
---|---|
protected long |
baseOffset
An offset which will be applied to each record written onto the
backing
FileChannel . |
IReopenChannel<FileChannel> |
opener
Used to re-open the
FileChannel in this class. |
counters, log, recordMap
Constructor and Description |
---|
WriteCache.FileChannelWriteCache(long baseOffset,
IBufferAccess buf,
boolean useChecksum,
boolean isHighlyAvailable,
boolean bufferHasData,
IReopenChannel<FileChannel> opener,
long fileExtent) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
writeOnChannel(ByteBuffer data,
long firstOffset,
Map<Long,WriteCache.RecordMetadata> recordMap,
long nanos)
Write the data from the buffer onto the channel.
|
allocate, bytesWritten, capacity, close, closeForWrites, contains, decrementReferenceCount, flush, flush, getCompressorKey, getCounters, getFileExtent, getLastOffset, getReferenceCount, incrementReferenceCount, isClosedForWrites, read, registerWriteStatus, reset, resetRecordMapFromBuffer, resetRecordMapFromBuffer, setFileExtent, setFirstOffset, setRecordMap, toString, write
protected final long baseOffset
FileChannel
. The offset is generally the size of the
root blocks for a journal or the checkpoint record for an index
segment. It can be zero if you do not have anything at the head of
the file.
Note: This implies that writing the root blocks is done separately in the protocol since you can't write below this offset otherwise.
public final IReopenChannel<FileChannel> opener
FileChannel
in this class.public WriteCache.FileChannelWriteCache(long baseOffset, IBufferAccess buf, boolean useChecksum, boolean isHighlyAvailable, boolean bufferHasData, IReopenChannel<FileChannel> opener, long fileExtent) throws InterruptedException
baseOffset
- An offsetbuf
- opener
- InterruptedException
protected boolean writeOnChannel(ByteBuffer data, long firstOffset, Map<Long,WriteCache.RecordMetadata> recordMap, long nanos) throws InterruptedException, IOException
WriteCache
Implementations of this method MAY support gathered writes, depending on
the channel. The necessary information to perform a gathered write is
present in the recordMap. On the other hand, the implementation
MAY require that the records in the cache are laid out for a WORM, in
which case WriteCache.getFirstOffset()
provides the starting offset for the
data to be written. The application MUST coordinate the requirements for
a R/W or WORM store with the use of the WriteCache
and the means
to write on the backing channel.
writeOnChannel
in class WriteCache
data
- The data to be written. Only the dirty bytes are visible in
this view. The implementation should write all bytes from the
current position to the limit.firstOffset
- The offset of the first record in the recordMap into the file
(may be relative to a base offset within the file). This is
provided as an optimization for the WORM which writes its
records contiguously on the backing store.recordMap
- The mapping of record offsets onto metadata about those
records.nanos
- The timeout for the operation in nanoseconds.true
if the operation was completed successfully
within the time alloted.InterruptedException
- if the thread was interrupted.IOException
- if there was an IO problem.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.