Class DataBufferHolder
java.lang.Object
com.illumon.iris.db.util.caching.redesign.DataBufferHolder
Holder for
ByteBuffer
s 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 TypeMethodDescriptionfinal void
clear()
Clear any state, in order to allow for re-use.final void
Clear the pending view, if there is one.final ByteBuffer
Get the current visible view for readers.final void
Promote the pending view, if non-null, to the current view.final ByteBuffer
Get a new view of the held buffer as if withByteBuffer.asReadOnlyBuffer()
, always with limit and position 0.final void
setCurrent
(ByteBuffer current) Set the current visible view for readers.final void
setPending
(ByteBuffer pending) Set the pending view for incomplete transactions still being written.final ByteBuffer
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.
-