Type Parameters:
A - The array type for transferring data in blocks
All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
SliceAccessorImpl

public interface SliceAccessor<A> extends AutoCloseable
Abstraction over a sequence of pages to view their content as consecutive items. The underlying pages may be claimed by multiple page ranges held by different clients. Clients must eventually close pages ranges in order to allow for resources to be freed. Note: The page range abstraction enables consumers and producers to claim the same pages independently. A consumer does not have to wait for the producers to advertise pages they are working on, instead the (low-level/internal) consumer can simply claim the pages it wants to read in advance and then schedule any needed executors. The claim range can be mutated which performs only the necessary (un)claim operations.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    addEvictionGuard(com.google.common.collect.Range<Long> range)
     
    void
    addEvictionGuard(com.google.common.collect.RangeSet<Long> ranges)
    Adds an eviction guard (if the slice supports it) and binds its life cycle to this accessor.
    void
    claimByOffsetRange(long startOffset, long endOffset)
    Set or update the claimed range - this will immediately request references to any pages providing the data for that range.
    void
    Closes the page range.
     
    void
    Lock the range for writing
    void
    Releases all currently held pages.
    void
    Unlock the range
    int
    unsafeRead(A tgt, int tgtOffset, long srcOffset, int length)
    Read operation that assumes a prior check for available ranges has been performed.
    void
    write(long offset, A arrayWithItemsOfTypeT, int arrOffset, int arrLength)
    Put a sequence of items into the claimed range Attempts to put items outside of the claimed range raises an IndexOutOfBoundsException The page range should be locked when calling this method.
  • Method Details

    • getSlice

      Slice<A> getSlice()
    • addEvictionGuard

      void addEvictionGuard(com.google.common.collect.RangeSet<Long> ranges)
      Adds an eviction guard (if the slice supports it) and binds its life cycle to this accessor. Closing an accessor thus also removes all eviction guards created by it. This method must be called after acquiring a read lock on the slice's metadata.
      Parameters:
      ranges - The set of ranges which to protected from eviction
    • addEvictionGuard

      default void addEvictionGuard(com.google.common.collect.Range<Long> range)
    • claimByOffsetRange

      void claimByOffsetRange(long startOffset, long endOffset)
      Set or update the claimed range - this will immediately request references to any pages providing the data for that range. Pages outside of that range are considered as no longer needed pages will immediately be released. This method prepares the pages which can be subsequently locked. Calling this method while the page range is locked (lock()) raises an IllegalStateException.
      Parameters:
      startOffset -
      endOffset -
    • lock

      void lock()
      Lock the range for writing
    • write

      void write(long offset, A arrayWithItemsOfTypeT, int arrOffset, int arrLength) throws IOException
      Put a sequence of items into the claimed range Attempts to put items outside of the claimed range raises an IndexOutOfBoundsException The page range should be locked when calling this method.
      Throws:
      IOException
    • unsafeRead

      int unsafeRead(A tgt, int tgtOffset, long srcOffset, int length) throws IOException
      Read operation that assumes a prior check for available ranges has been performed. Only use this method after locking.
      Throws:
      IOException
    • unlock

      void unlock()
      Unlock the range
    • releaseAll

      void releaseAll()
      Releases all currently held pages. Future requests via claimByOffsetRange(long, long) are allowed.
    • close

      void close()
      Closes the page range. Implementations of this method should call {releaseAll() and an addition prevent any further claims.
      Specified by:
      close in interface AutoCloseable