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