public class CachedBlock extends Object implements HeapSize, Comparable<CachedBlock>
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 | Class and Description |
---|---|
static class |
CachedBlock.BlockPriority |
Modifier and Type | Field and Description |
---|---|
static long |
PER_BLOCK_OVERHEAD |
Constructor and Description |
---|
CachedBlock(String blockName,
byte[] buf,
long accessTime,
boolean inMemory) |
Modifier and Type | Method and Description |
---|---|
void |
access(long accessTime)
Block has been accessed.
|
int |
compareTo(CachedBlock that) |
boolean |
equals(Object obj) |
long |
evicted(AtomicLong totalSize) |
byte[] |
getBuffer() |
<T extends CacheEntry.Weighable> |
getIndex(Supplier<T> supplier) |
String |
getName() |
CachedBlock.BlockPriority |
getPriority() |
int |
hashCode() |
long |
heapSize() |
long |
recordSize(AtomicLong totalSize) |
public CachedBlock(String blockName, byte[] buf, long accessTime, boolean inMemory)
public void access(long accessTime)
public long heapSize()
public int compareTo(CachedBlock that)
compareTo
in interface Comparable<CachedBlock>
public String getName()
public CachedBlock.BlockPriority getPriority()
public byte[] getBuffer()
public <T extends CacheEntry.Weighable> T getIndex(Supplier<T> supplier)
public long recordSize(AtomicLong totalSize)
public long evicted(AtomicLong totalSize)
Copyright © 2011–2019 The Apache Software Foundation. All rights reserved.