Class OpportunisticBlockCache
- java.lang.Object
-
- org.apache.accumulo.core.file.blockfile.impl.OpportunisticBlockCache
-
- All Implemented Interfaces:
BlockCache
public class OpportunisticBlockCache extends Object implements BlockCache
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.accumulo.core.spi.cache.BlockCache
BlockCache.Loader, BlockCache.Stats
-
-
Constructor Summary
Constructors Constructor Description OpportunisticBlockCache(BlockCache cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CacheEntrycacheBlock(String blockName, byte[] buf)Add block to cache.CacheEntrygetBlock(String blockName)Fetch block from cache.CacheEntrygetBlock(String blockName, BlockCache.Loader loader)This method allows a cache to prevent concurrent loads of the same block.longgetMaxHeapSize()Get the maximum amount of on heap memory this cache will use.longgetMaxSize()Get the maximum size of this cache.BlockCache.StatsgetStats()Get the statistics of this cache.
-
-
-
Constructor Detail
-
OpportunisticBlockCache
public OpportunisticBlockCache(BlockCache cache)
-
-
Method Detail
-
cacheBlock
public CacheEntry cacheBlock(String blockName, byte[] buf)
Description copied from interface:BlockCacheAdd block to cache.- Specified by:
cacheBlockin interfaceBlockCache- 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:BlockCacheFetch block from cache.- Specified by:
getBlockin interfaceBlockCache- 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:BlockCacheThis method allows a cache to prevent concurrent loads of the same block. However a cache implementation is not required to prevent concurrent loads.SynchronousLoadingBlockCacheis an abstract class that a cache can extent which does prevent concurrent loading of the same block.- Specified by:
getBlockin interfaceBlockCache- Parameters:
blockName- Block name to fetchloader- 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:BlockCacheGet the maximum amount of on heap memory this cache will use.- Specified by:
getMaxHeapSizein interfaceBlockCache
-
getMaxSize
public long getMaxSize()
Description copied from interface:BlockCacheGet the maximum size of this cache.- Specified by:
getMaxSizein interfaceBlockCache- Returns:
- max size in bytes
-
getStats
public BlockCache.Stats getStats()
Description copied from interface:BlockCacheGet the statistics of this cache.- Specified by:
getStatsin interfaceBlockCache- Returns:
- statistics
-
-