@InterfaceAudience.Private public class CombinedBlockCache extends Object implements ResizableBlockCache, HeapSize
LruBlockCache and BucketCache. The smaller lruCache is used
to cache bloom blocks and index blocks. The larger Cache is used to
cache data blocks. getBlock(BlockCacheKey, boolean, boolean, boolean) reads
first from the smaller lruCache before looking for the block in the l2Cache.
Metrics are the combined size and hits and misses of both caches.| 限定符和类型 | 类和说明 |
|---|---|
static class |
CombinedBlockCache.CombinedCacheStats |
| 限定符和类型 | 字段和说明 |
|---|---|
protected CombinedBlockCache.CombinedCacheStats |
combinedCacheStats |
protected BlockCache |
l2Cache |
protected LruBlockCache |
onHeapCache |
| 构造器和说明 |
|---|
CombinedBlockCache(LruBlockCache onHeapCache,
BlockCache l2Cache) |
| 限定符和类型 | 方法和说明 |
|---|---|
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 |
getCurrentDataSize()
Returns the occupied size of data blocks, in bytes.
|
long |
getCurrentSize()
Returns the occupied size of the block cache, in bytes.
|
long |
getDataBlockCount()
Returns the number of data blocks currently cached in the block cache.
|
long |
getFreeSize()
Returns the free size of the block cache, in bytes.
|
long |
getMaxSize()
Returns the Max size of the block cache, in bytes.
|
int |
getRefCount(BlockCacheKey cacheKey) |
CacheStats |
getStats()
Get the statistics for this block cache.
|
long |
heapSize() |
Iterator<CachedBlock> |
iterator() |
void |
returnBlock(BlockCacheKey cacheKey,
Cacheable block)
Called when the scanner using the block decides to return the block once its usage
is over.
|
void |
setMaxSize(long size)
Sets the max heap size that can be used by the BlockCache.
|
void |
shutdown()
Shutdown the cache.
|
long |
size()
Returns the total size of the block cache, in bytes.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected final LruBlockCache onHeapCache
protected final BlockCache l2Cache
protected final CombinedBlockCache.CombinedCacheStats combinedCacheStats
public CombinedBlockCache(LruBlockCache onHeapCache, BlockCache l2Cache)
public void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
BlockCachecacheBlock 在接口中 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 在接口中 BlockCachecacheKey - The block's cache key.buf - The object to cache.public Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat, boolean updateCacheMetrics)
BlockCachegetBlock 在接口中 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 在接口中 BlockCachecacheKey - Block to evictpublic int evictBlocksByHfileName(String hfileName)
BlockCacheevictBlocksByHfileName 在接口中 BlockCachepublic CacheStats getStats()
BlockCachegetStats 在接口中 BlockCachepublic void shutdown()
BlockCacheshutdown 在接口中 BlockCachepublic long size()
BlockCachesize 在接口中 BlockCachepublic long getMaxSize()
BlockCachegetMaxSize 在接口中 BlockCachepublic long getCurrentDataSize()
BlockCachegetCurrentDataSize 在接口中 BlockCachepublic long getFreeSize()
BlockCachegetFreeSize 在接口中 BlockCachepublic long getCurrentSize()
BlockCachegetCurrentSize 在接口中 BlockCachepublic long getBlockCount()
BlockCachegetBlockCount 在接口中 BlockCachepublic long getDataBlockCount()
BlockCachegetDataBlockCount 在接口中 BlockCachepublic Iterator<CachedBlock> iterator()
iterator 在接口中 Iterable<CachedBlock>iterator 在接口中 BlockCachepublic BlockCache[] getBlockCaches()
getBlockCaches 在接口中 BlockCachepublic void setMaxSize(long size)
ResizableBlockCachesetMaxSize 在接口中 ResizableBlockCachesize - The max heap size.public void returnBlock(BlockCacheKey cacheKey, Cacheable block)
BlockCacheCacheable.MemoryType.returnBlock 在接口中 BlockCachecacheKey - the cache key of the blockblock - the hfileblock to be returnedpublic int getRefCount(BlockCacheKey cacheKey)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.