Interface BlockCache
-
- All Known Implementing Classes:
LruBlockCache
,OpportunisticBlockCache
,SynchronousLoadingBlockCache
,TinyLfuBlockCache
public interface BlockCache
Block cache interface.- Since:
- 2.0.0
- See Also:
org.apache.accumulo.core.spi
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
BlockCache.Loader
static interface
BlockCache.Stats
Cache statistics.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CacheEntry
cacheBlock(String blockName, byte[] buf)
Add block to cache.CacheEntry
getBlock(String blockName)
Fetch block from cache.CacheEntry
getBlock(String blockName, BlockCache.Loader loader)
This method allows a cache to prevent concurrent loads of the same block.long
getMaxHeapSize()
Get the maximum amount of on heap memory this cache will use.long
getMaxSize()
Get the maximum size of this cache.BlockCache.Stats
getStats()
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.SynchronousLoadingBlockCache
is 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
-
-