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 Details

    • getCurrent

      public final ByteBuffer getCurrent()
      Get the current visible view for readers. Must not be mutated.
      Returns:
      The current visible view
    • setCurrent

      public final void setCurrent​(@NotNull ByteBuffer current)

      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

      public final ByteBuffer writableView()
      Get a new view of the held buffer as if with ByteBuffer.duplicate(), always with limit and position 0.
      Returns:
      The new view, which belongs to the caller to mutate until given back with setCurrent(ByteBuffer) or setPending(ByteBuffer).
    • readOnlyView

      public final ByteBuffer readOnlyView()
      Get a new view of the held buffer as if with ByteBuffer.asReadOnlyBuffer(), always with limit and position 0.
      Returns:
      The new view, which belongs to the caller to mutate
    • setPending

      public final void setPending​(@NotNull ByteBuffer pending)

      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.