@InterfaceAudience.Private public class LruCachedBlock extends Object implements HeapSize, Comparable<LruCachedBlock>
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.
Modifier and Type | Field and Description |
---|---|
private long |
accessTime |
private Cacheable |
buf |
private long |
cachedTime
Time this block was cached.
|
private BlockCacheKey |
cacheKey |
static long |
PER_BLOCK_OVERHEAD |
private BlockPriority |
priority |
private long |
size |
Constructor and Description |
---|
LruCachedBlock(BlockCacheKey cacheKey,
Cacheable buf,
long accessTime) |
LruCachedBlock(BlockCacheKey cacheKey,
Cacheable buf,
long accessTime,
boolean inMemory) |
Modifier and Type | Method and Description |
---|---|
void |
access(long accessTime)
Block has been accessed.
|
int |
compareTo(LruCachedBlock that) |
boolean |
equals(Object obj) |
Cacheable |
getBuffer() |
long |
getCachedTime() |
BlockCacheKey |
getCacheKey() |
BlockPriority |
getPriority() |
int |
hashCode() |
long |
heapSize() |
public static final long PER_BLOCK_OVERHEAD
private final BlockCacheKey cacheKey
private final Cacheable buf
private volatile long accessTime
private long size
private BlockPriority priority
private final long cachedTime
public LruCachedBlock(BlockCacheKey cacheKey, Cacheable buf, long accessTime)
public LruCachedBlock(BlockCacheKey cacheKey, Cacheable buf, long accessTime, boolean inMemory)
public void access(long accessTime)
accessTime
- Last access; this is actually a incremented sequence number rather than an
actual time.public long getCachedTime()
public long heapSize()
public int compareTo(LruCachedBlock that)
compareTo
in interface Comparable<LruCachedBlock>
public Cacheable getBuffer()
public BlockCacheKey getCacheKey()
public BlockPriority getPriority()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.