Class PagingContextHolder

All Implemented Interfaces:
ChunkSource.FillContext, Context, SafeCloseable, AutoCloseable

public class PagingContextHolder extends Object implements ChunkSource.FillContext
ChunkSource.FillContext implementation for use by PagingChunkSource implementations. This is basically a re-usable box around an inner context object, filled with whatever the most recently used Page chose to store.
  • Constructor Details

    • PagingContextHolder

      public PagingContextHolder(int chunkCapacity, @Nullable @Nullable SharedContext sharedContext)
  • Method Details

    • supportsUnboundedFill

      public boolean supportsUnboundedFill()
      Returns true if this Context contains internal state that limits its capacity to the originally requested capacity. If false is returned, then fillChunk operations may be arbitrarily large.
      Specified by:
      supportsUnboundedFill in interface ChunkSource.FillContext
      if this context has a limited capacity
      This implementation always returns true, as the PageStore fill implementation follows an append pattern over multiple pages when necessary, and all known inner context implementations trivially support unbounded fill. We thus make this a requirement for future inner context implementations, either naturally or via a slicing/looping pattern.
    • getChunkCapacity

      public int getChunkCapacity()
      Get the chunk capacity this holder was created with.
      The chunk capacity
    • getSharedContext

      public SharedContext getSharedContext()
      Get the SharedContext this holder was created with.
      The SharedContext
    • getInnerContext

      public <T extends Context> T getInnerContext()
      Get the inner context value set by setInnerContext(Context) and cast it to the templated type.
      Type Parameters:
      T - The desired result type
      The inner context value
    • setInnerContext

      public void setInnerContext(@Nullable @Nullable Context newInnerContext)
      Set the inner context object for use by the current region. The previous inner context will be closed.
      newInnerContext - The new context object
    • updateInnerContext

      public <T extends Context> T updateInnerContext(@NotNull @NotNull PagingContextHolder.Updater updater)
      Update the inner context value using the provided updater.
      Type Parameters:
      T - The desired result type
      updater - The PagingContextHolder.Updater to use
      The result of updater
    • close

      public void close()
      Description copied from interface: Context
      Release any resources associated with this context. The context should not be used afterwards.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Context
      Specified by:
      close in interface SafeCloseable