org.apache.hadoop.hbase.io.hfile
Class LruCachedBlock

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.LruCachedBlock
All Implemented Interfaces:
Comparable<LruCachedBlock>, HeapSize

@InterfaceAudience.Private
public class LruCachedBlock
extends Object
implements HeapSize, Comparable<LruCachedBlock>

Represents an entry in the LruBlockCache.

Makes the block memory-aware with HeapSize and Comparable to sort by access time for the LRU. It also takes care of priority by either instantiating as in-memory or handling the transition from single to multiple access.


Field Summary
static long PER_BLOCK_OVERHEAD
           
 
Constructor Summary
LruCachedBlock(BlockCacheKey cacheKey, Cacheable buf, long accessTime)
           
LruCachedBlock(BlockCacheKey cacheKey, Cacheable buf, long accessTime, boolean inMemory)
           
 
Method Summary
 void access(long accessTime)
          Block has been accessed.
 int compareTo(LruCachedBlock that)
           
 boolean equals(Object obj)
           
 Cacheable getBuffer()
           
 long getCachedTime()
           
 BlockCacheKey getCacheKey()
           
 BlockPriority getPriority()
           
 long heapSize()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PER_BLOCK_OVERHEAD

public static final long PER_BLOCK_OVERHEAD
Constructor Detail

LruCachedBlock

public LruCachedBlock(BlockCacheKey cacheKey,
                      Cacheable buf,
                      long accessTime)

LruCachedBlock

public LruCachedBlock(BlockCacheKey cacheKey,
                      Cacheable buf,
                      long accessTime,
                      boolean inMemory)
Method Detail

access

public void access(long accessTime)
Block has been accessed.

Parameters:
accessTime - Last access; this is actually a incremented sequence number rather than an actual time.

getCachedTime

public long getCachedTime()
Returns:
Time we were cached at in nano seconds.

heapSize

public long heapSize()
Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.

compareTo

public int compareTo(LruCachedBlock that)
Specified by:
compareTo in interface Comparable<LruCachedBlock>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getBuffer

public Cacheable getBuffer()

getCacheKey

public BlockCacheKey getCacheKey()

getPriority

public BlockPriority getPriority()


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.