@InterfaceAudience.Private public class CombinedBlockCache extends Object implements BlockCache, HeapSize
LruBlockCache and BucketCache. The smaller lruCache is used
to cache bloom blocks and index blocks , the larger bucketCache is used to
cache data blocks. getBlock reads first from the smaller lruCache before
looking for the block in the bucketCache. Metrics are the combined size and
hits and misses of both caches.| Constructor and Description |
|---|
CombinedBlockCache(LruBlockCache lruCache,
BucketCache bucketCache) |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable buf)
Add block to cache (defaults to not in-memory).
|
void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable buf,
boolean inMemory)
Add block to cache.
|
boolean |
evictBlock(BlockCacheKey cacheKey)
Evict block from cache.
|
int |
evictBlocksByHfileName(String hfileName)
Evicts all blocks for the given HFile.
|
Cacheable |
getBlock(BlockCacheKey cacheKey,
boolean caching,
boolean repeat,
boolean updateCacheMetrics)
Fetch block from cache.
|
BlockCache[] |
getBlockCaches() |
long |
getBlockCount()
Returns the number of blocks currently cached in the block cache.
|
long |
getCurrentSize()
Returns the occupied size of the block cache, in bytes.
|
long |
getFreeSize()
Returns the free size of the block cache, in bytes.
|
CacheStats |
getStats()
Get the statistics for this block cache.
|
long |
heapSize() |
Iterator<CachedBlock> |
iterator() |
void |
shutdown()
Shutdown the cache.
|
long |
size()
Returns the total size of the block cache, in bytes.
|
public CombinedBlockCache(LruBlockCache lruCache, BucketCache bucketCache)
public long heapSize()
public void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
BlockCachecacheBlock in interface BlockCachecacheKey - The block's cache key.buf - The block contents wrapped in a ByteBuffer.inMemory - Whether block should be treated as in-memorypublic void cacheBlock(BlockCacheKey cacheKey, Cacheable buf)
BlockCachecacheBlock in interface BlockCachecacheKey - The block's cache key.buf - The object to cache.public Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat, boolean updateCacheMetrics)
BlockCachegetBlock in interface BlockCachecacheKey - Block to fetch.caching - Whether this request has caching enabled (used for stats)repeat - Whether this is a repeat lookup for the same block
(used to avoid double counting cache misses when doing double-check locking)updateCacheMetrics - Whether to update cache metrics or notpublic boolean evictBlock(BlockCacheKey cacheKey)
BlockCacheevictBlock in interface BlockCachecacheKey - Block to evictpublic int evictBlocksByHfileName(String hfileName)
BlockCacheevictBlocksByHfileName in interface BlockCachepublic CacheStats getStats()
BlockCachegetStats in interface BlockCachepublic void shutdown()
BlockCacheshutdown in interface BlockCachepublic long size()
BlockCachesize in interface BlockCachepublic long getFreeSize()
BlockCachegetFreeSize in interface BlockCachepublic long getCurrentSize()
BlockCachegetCurrentSize in interface BlockCachepublic long getBlockCount()
BlockCachegetBlockCount in interface BlockCachepublic Iterator<CachedBlock> iterator()
iterator in interface Iterable<CachedBlock>iterator in interface BlockCachepublic BlockCache[] getBlockCaches()
getBlockCaches in interface BlockCacheCopyright © 2014 The Apache Software Foundation. All rights reserved.