Class SliceInMemoryCache<A>

java.lang.Object
org.aksw.commons.io.slice.SliceBase<A>
org.aksw.commons.io.slice.SliceInMemoryCache<A>
All Implemented Interfaces:
Slice<A>, SliceMetaDataBasic, SliceWithPages<A>, org.aksw.commons.io.util.Sync, org.aksw.commons.util.range.PageHelper

public class SliceInMemoryCache<A> extends SliceBase<A> implements SliceWithPages<A>
A slice implementation that starts to discard pages once there are too many.
Author:
raven
  • Field Details

  • Constructor Details

    • SliceInMemoryCache

      protected SliceInMemoryCache(ArrayOps<A> arrayOps, int pageSize, org.aksw.commons.cache.async.AsyncClaimingCacheImpl.Builder<Long,BufferView<A>> cacheBuilder)
  • Method Details

    • create

      public static <A> Slice<A> create(ArrayOps<A> arrayOps, int pageSize, int maxCachedPages)
    • evictPage

      protected void evictPage(long pageId)
    • loadPage

      protected BufferView<A> loadPage(long pageId)
    • create

      public static <A> SliceInMemory<A> create(ArrayOps<A> arrayOps, Buffer<A> buffer)
    • getMetaData

      protected SliceMetaDataBasic getMetaData()
      Specified by:
      getMetaData in class SliceBase<A>
    • sync

      public void sync() throws IOException
      Specified by:
      sync in interface org.aksw.commons.io.util.Sync
      Throws:
      IOException
    • getPageSize

      public long getPageSize()
      Specified by:
      getPageSize in interface org.aksw.commons.util.range.PageHelper
      Specified by:
      getPageSize in interface SliceWithPages<A>
    • getPageForPageId

      public org.aksw.commons.util.ref.RefFuture<BufferView<A>> getPageForPageId(long pageId)
      Specified by:
      getPageForPageId in interface SliceWithPages<A>
    • addEvictionGuard

      public org.aksw.commons.util.closeable.Disposable addEvictionGuard(com.google.common.collect.RangeSet<Long> ranges)
      Description copied from interface: Slice
      Protect a set of ranges from eviction. If the slice does make use of eviction then this method can return null. Otherwise, a disposable must be returned. As long as it is not disposed no data in the range may get lost due to eviction. This method should not be used directly but via
      invalid @link
      {@link SliceAccessor#addEvictionGuard(RangeSet))
      }.
      Specified by:
      addEvictionGuard in interface Slice<A>