Package org.apache.cassandra.io.util
Class WrappingRebufferer
java.lang.Object
org.apache.cassandra.io.util.WrappingRebufferer
- All Implemented Interfaces:
AutoCloseable,ReaderFileProxy,Rebufferer,Rebufferer.BufferHolder
- Direct Known Subclasses:
LimitingRebufferer,TailOverridingRebufferer
@NotThreadSafe
public abstract class WrappingRebufferer
extends Object
implements Rebufferer, Rebufferer.BufferHolder
Instantiated once per RandomAccessReader, thread-unsafe.
The instances reuse themselves as the BufferHolder to avoid having to return a new object for each rebuffer call.
Only one buffer holder can be active at a time. Calling
rebuffer(long) before the previously obtained
buffer holder is released will throw AssertionError. We will get that exception also in case we try to close
the rebufferer without closing the recently obtained buffer holder.
Calling methods of Rebufferer.BufferHolder will also produce AssertionError if buffer holder is not acquired.
The overriding classes must conform to the aforementioned rules.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.io.util.Rebufferer
Rebufferer.BufferHolder -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ByteBufferprotected Rebufferer.BufferHolderprotected longprotected final RebuffererFields inherited from interface org.apache.cassandra.io.util.Rebufferer
EMPTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuffer()Returns a useable buffer (i.e.channel()voidclose()voidCalled when a reader is closed.longdoubleNeeded for tests.longoffset()Position in the file of the start of the buffer.rebuffer(long position) Rebuffer (move on or seek to) a given position, and return a buffer that can be used there.voidrelease()To be called when this buffer is no longer in use.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cassandra.io.util.Rebufferer.BufferHolder
floatBuffer, intBuffer
-
Field Details
-
wrapped
-
bufferHolder
-
buffer
-
offset
protected long offset
-
-
Constructor Details
-
WrappingRebufferer
-
-
Method Details
-
rebuffer
Description copied from interface:RebuffererRebuffer (move on or seek to) a given position, and return a buffer that can be used there. The only guarantee about the size of the returned data is that unless rebuffering at the end of the file, the buffer will not be empty and will contain the requested position, i.e.offset <= position < offset + bh.buffer().limit(), but the buffer will not be positioned there.- Specified by:
rebufferin interfaceRebufferer
-
channel
- Specified by:
channelin interfaceReaderFileProxy
-
fileLength
public long fileLength()- Specified by:
fileLengthin interfaceReaderFileProxy
-
getCrcCheckChance
public double getCrcCheckChance()Description copied from interface:ReaderFileProxyNeeded for tests. Returns the table's CRC check chance, which is only set for compressed tables.- Specified by:
getCrcCheckChancein interfaceReaderFileProxy
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceReaderFileProxy
-
closeReader
public void closeReader()Description copied from interface:RebuffererCalled when a reader is closed. Should clean up reader-specific data.- Specified by:
closeReaderin interfaceRebufferer
-
toString
-
buffer
Description copied from interface:Rebufferer.BufferHolderReturns a useable buffer (i.e. one whose position and limit can be freely modified). Its limit will be set to the size of the available data in the buffer. The buffer must be treated as read-only.- Specified by:
bufferin interfaceRebufferer.BufferHolder
-
offset
public long offset()Description copied from interface:Rebufferer.BufferHolderPosition in the file of the start of the buffer.- Specified by:
offsetin interfaceRebufferer.BufferHolder
-
release
public void release()Description copied from interface:Rebufferer.BufferHolderTo be called when this buffer is no longer in use. Must be called for all BufferHolders, or ChunkCache will not be able to free blocks.- Specified by:
releasein interfaceRebufferer.BufferHolder
-