Class DataBufferHolder
java.lang.Object
com.illumon.iris.db.util.caching.redesign.DataBufferHolder
public final class DataBufferHolder extends Object
Holder for
ByteBuffers pooled in the DataBufferPool and associated views. Manages visibility
for readers, transaction buffering for writers, and other state associated with a given data buffer.-
Method Summary
Modifier and Type Method Description voidclear()Clear any state, in order to allow for re-use.voidclearPending()Clear the pending view, if there is one.ByteBuffergetCurrent()Get the current visible view for readers.voidpromotePending()Promote the pending view, if non-null, to the current view.ByteBufferreadOnlyView()Get a new view of the held buffer as if withByteBuffer.asReadOnlyBuffer(), always with limit and position 0.voidsetCurrent(ByteBuffer current)Set the current visible view for readers.voidsetPending(ByteBuffer pending)Set the pending view for incomplete transactions still being written.ByteBufferwritableView()Get a new view of the held buffer as if withByteBuffer.duplicate(), always with limit and position 0.
-
Method Details
-
getCurrent
Get the current visible view for readers. Must not be mutated.- Returns:
- The current visible view
-
setCurrent
Set the current visible view for readers.
The input buffer must have been created with
writableView()and must not be mutated further by application code after it is passed to this method.- Parameters:
current- The new current visible view
-
writableView
Get a new view of the held buffer as if withByteBuffer.duplicate(), always with limit and position 0.- Returns:
- The new view, which belongs to the caller to mutate until given back with
setCurrent(ByteBuffer)orsetPending(ByteBuffer).
-
readOnlyView
Get a new view of the held buffer as if withByteBuffer.asReadOnlyBuffer(), always with limit and position 0.- Returns:
- The new view, which belongs to the caller to mutate
-
setPending
Set the pending view for incomplete transactions still being written.
The input buffer must have been created with
writableView()and must not be mutated further by application code after it is passed to this method.- Parameters:
pending- The new pending view
-
promotePending
public final void promotePending()Promote the pending view, if non-null, to the current view. Clear the pending view. -
clearPending
public final void clearPending()Clear the pending view, if there is one. -
clear
public final void clear()Clear any state, in order to allow for re-use.
-