Class OpportunisticBlockCache

    • Constructor Detail

      • OpportunisticBlockCache

        public OpportunisticBlockCache​(BlockCache cache)
    • Method Detail

      • cacheBlock

        public CacheEntry cacheBlock​(String blockName,
                                     byte[] buf)
        Description copied from interface: BlockCache
        Add block to cache.
        Specified by:
        cacheBlock in interface BlockCache
        Parameters:
        blockName - Zero-based file block number.
        buf - The block contents wrapped in a ByteBuffer.
      • getBlock

        public CacheEntry getBlock​(String blockName)
        Description copied from interface: BlockCache
        Fetch block from cache.
        Specified by:
        getBlock in interface BlockCache
        Parameters:
        blockName - Block name to fetch.
        Returns:
        Block or null if block is not in the cache.
      • getBlock

        public CacheEntry getBlock​(String blockName,
                                   BlockCache.Loader loader)
        Description copied from interface: BlockCache
        This method allows a cache to prevent concurrent loads of the same block. However a cache implementation is not required to prevent concurrent loads. SynchronousLoadingBlockCache is an abstract class that a cache can extent which does prevent concurrent loading of the same block.
        Specified by:
        getBlock in interface BlockCache
        Parameters:
        blockName - Block name to fetch
        loader - If the block is not present in the cache, the loader can be called to load it.
        Returns:
        Block or null if block is not in the cache or didn't load.
      • getMaxHeapSize

        public long getMaxHeapSize()
        Description copied from interface: BlockCache
        Get the maximum amount of on heap memory this cache will use.
        Specified by:
        getMaxHeapSize in interface BlockCache
      • getMaxSize

        public long getMaxSize()
        Description copied from interface: BlockCache
        Get the maximum size of this cache.
        Specified by:
        getMaxSize in interface BlockCache
        Returns:
        max size in bytes