|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.io.hfile.slab.SingleSizeCache
public class SingleSizeCache
SingleSizeCache is a slab allocated cache that caches elements up to a single size. It uses a slab allocator (Slab.java) to divide a direct bytebuffer, into evenly sized blocks. Any cached data will take up exactly 1 block. An exception will be thrown if the cached data cannot fit into the blockSize of this SingleSizeCache. Eviction and LRUness is taken care of by Guava's MapMaker, which creates a ConcurrentLinkedHashMap.
| Field Summary | |
|---|---|
static long |
CACHE_FIXED_OVERHEAD
|
| Constructor Summary | |
|---|---|
SingleSizeCache(int blockSize,
int numBlocks,
org.apache.hadoop.hbase.io.hfile.slab.SlabItemActionWatcher master)
Default constructor. |
|
| Method Summary | |
|---|---|
void |
cacheBlock(String blockName,
Cacheable toBeCached)
Add block to cache (defaults to not in-memory). |
void |
cacheBlock(String blockName,
Cacheable buf,
boolean inMemory)
Add block to cache. |
boolean |
evictBlock(String key)
Evicts the block |
int |
evictBlocksByPrefix(String prefix)
Evicts all blocks with name starting with the given prefix. |
Cacheable |
getBlock(String key,
boolean caching)
Fetch block from cache. |
List<BlockCacheColumnFamilySummary> |
getBlockCacheColumnFamilySummaries(org.apache.hadoop.conf.Configuration conf)
Performs a BlockCache summary and returns a List of BlockCacheColumnFamilySummary objects. |
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 |
getEvictedCount()
Returns the number of evictions that have occurred. |
long |
getFreeSize()
Returns the free size of the block cache, in bytes. |
long |
getOccupiedSize()
|
CacheStats |
getStats()
Get the statistics for this block cache. |
long |
heapSize()
|
void |
logStats()
|
void |
shutdown()
Shutdown the cache. |
long |
size()
Returns the total size of the block cache, in bytes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long CACHE_FIXED_OVERHEAD
| Constructor Detail |
|---|
public SingleSizeCache(int blockSize,
int numBlocks,
org.apache.hadoop.hbase.io.hfile.slab.SlabItemActionWatcher master)
blockSize - the size of each block, in bytesnumBlocks - the number of blocks of blockSize this cache will hold.master - the SlabCache this SingleSlabCache is assigned to.| Method Detail |
|---|
public void cacheBlock(String blockName,
Cacheable toBeCached)
BlockCache
cacheBlock in interface BlockCacheblockName - Zero-based file block number.toBeCached - The object to cache.
public Cacheable getBlock(String key,
boolean caching)
BlockCache
getBlock in interface BlockCachekey - Block number to fetch.caching - Whether this request has caching enabled (used for stats)
public boolean evictBlock(String key)
evictBlock in interface BlockCachekey - the key of the entry we are going to evict
public void logStats()
public void shutdown()
BlockCache
shutdown in interface BlockCachepublic long heapSize()
heapSize in interface HeapSizepublic long size()
BlockCache
size in interface BlockCachepublic long getFreeSize()
BlockCache
getFreeSize in interface BlockCachepublic long getOccupiedSize()
public long getEvictedCount()
BlockCache
getEvictedCount in interface BlockCachepublic CacheStats getStats()
BlockCache
getStats in interface BlockCachepublic long getBlockCount()
BlockCache
getBlockCount in interface BlockCache
public void cacheBlock(String blockName,
Cacheable buf,
boolean inMemory)
BlockCache
cacheBlock in interface BlockCacheblockName - Zero-based file block number.buf - The block contents wrapped in a ByteBuffer.inMemory - Whether block should be treated as in-memorypublic int evictBlocksByPrefix(String prefix)
BlockCache
evictBlocksByPrefix in interface BlockCachepublic long getCurrentSize()
BlockCache
getCurrentSize in interface BlockCachepublic List<BlockCacheColumnFamilySummary> getBlockCacheColumnFamilySummaries(org.apache.hadoop.conf.Configuration conf)
BlockCache
getBlockCacheColumnFamilySummaries in interface BlockCacheconf - HBaseConfiguration
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||