Interface BlockCache
-
- All Known Implementing Classes:
LruBlockCache,OpportunisticBlockCache,SynchronousLoadingBlockCache,TinyLfuBlockCache
public interface BlockCacheBlock cache interface.- Since:
- 2.0.0
- See Also:
org.apache.accumulo.core.spi
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceBlockCache.Loaderstatic interfaceBlockCache.StatsCache statistics.
-
Method Summary
All Methods Instance Methods Abstract 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.
-
-
-
Method Detail
-
cacheBlock
CacheEntry cacheBlock(String blockName, byte[] buf)
Add block to cache.- Parameters:
blockName- Zero-based file block number.buf- The block contents wrapped in a ByteBuffer.
-
getBlock
CacheEntry getBlock(String blockName)
Fetch block from cache.- Parameters:
blockName- Block name to fetch.- Returns:
- Block or null if block is not in the cache.
-
getBlock
CacheEntry getBlock(String blockName, BlockCache.Loader loader)
This 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.- 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
long getMaxHeapSize()
Get the maximum amount of on heap memory this cache will use.
-
getMaxSize
long getMaxSize()
Get the maximum size of this cache.- Returns:
- max size in bytes
-
getStats
BlockCache.Stats getStats()
Get the statistics of this cache.- Returns:
- statistics
-
-