@InterfaceAudience.Private public interface BlockCache extends Iterable<CachedBlock>
Cacheable
interface can be put in the cache.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 |
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.
|
CacheStats |
getStats()
Get the statistics for this block cache.
|
Iterator<CachedBlock> |
iterator() |
default void |
returnBlock(BlockCacheKey cacheKey,
Cacheable block)
Called when the scanner using the block decides to return the block once its usage
is over.
|
void |
shutdown()
Shutdown the cache.
|
long |
size()
Returns the total size of the block cache, in bytes.
|
forEach, spliterator
void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
cacheKey
- The block's cache key.buf
- The block contents wrapped in a ByteBuffer.inMemory
- Whether block should be treated as in-memoryvoid cacheBlock(BlockCacheKey cacheKey, Cacheable buf)
cacheKey
- The block's cache key.buf
- The object to cache.Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat, boolean updateCacheMetrics)
cacheKey
- 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 notboolean evictBlock(BlockCacheKey cacheKey)
cacheKey
- Block to evictint evictBlocksByHfileName(String hfileName)
CacheStats getStats()
void shutdown()
long size()
long getMaxSize()
long getFreeSize()
long getCurrentSize()
long getCurrentDataSize()
long getBlockCount()
long getDataBlockCount()
Iterator<CachedBlock> iterator()
iterator
in interface Iterable<CachedBlock>
BlockCache[] getBlockCaches()
default void returnBlock(BlockCacheKey cacheKey, Cacheable block)
Cacheable.MemoryType
.cacheKey
- the cache key of the blockblock
- the hfileblock to be returnedCopyright © 2007–2019 Cloudera. All rights reserved.