protected static class LruHashMap.Entry<K extends HeapSize,V extends HeapSize> extends Object implements Map.Entry<K,V>, HeapSize
Contains previous and next pointers for the doubly linked-list which is used for LRU eviction.
Instantiations of this class are memory aware. Both the key and value
classes used must also implement HeapSize
.
Modifier and Type | Field and Description |
---|---|
protected int |
hash
The hash value for this entries key
|
protected long |
heapSize
The precomputed heap size of this entry
|
protected K |
key
The key
|
protected LruHashMap.Entry<K,V> |
next
The next entry in the hash chain (for collisions)
|
protected LruHashMap.Entry<K,V> |
nextPtr
The next entry in the LRU list (towards MRU)
|
protected LruHashMap.Entry<K,V> |
prevPtr
The previous entry in the LRU list (towards LRU)
|
protected V |
value
The value
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Returns true is the specified entry has the same key and the
same value as this entry.
|
K |
getKey()
Get the key of this entry.
|
protected LruHashMap.Entry<K,V> |
getNextPtr()
Returns the next pointer for the entry in teh LRU.
|
protected LruHashMap.Entry<K,V> |
getPrevPtr()
Returns the previous pointer for the entry in the LRU.
|
V |
getValue()
Get the value of this entry.
|
int |
hashCode()
Returns the hash code of the entry by xor'ing the hash values
of the key and value of this entry.
|
long |
heapSize()
Returns the pre-computed and "deep" size of the Entry
|
protected long |
replaceValue(V newValue)
Replace the value of this entry.
|
protected void |
setNextPtr(LruHashMap.Entry<K,V> nextPtr)
Sets the next pointer for the entry in the LRU.
|
protected void |
setPrevPtr(LruHashMap.Entry<K,V> prevPtr)
Sets the previous pointer for the entry in the LRU.
|
V |
setValue(V newValue)
Set the value of this entry.
|
String |
toString()
Returns String representation of the entry in form "key=value"
|
protected final int hash
protected LruHashMap.Entry<K extends HeapSize,V extends HeapSize> next
protected LruHashMap.Entry<K extends HeapSize,V extends HeapSize> prevPtr
protected LruHashMap.Entry<K extends HeapSize,V extends HeapSize> nextPtr
protected long heapSize
public K getKey()
public V getValue()
public V setValue(V newValue)
replaceValue
will return the difference
in heap usage between the previous and current values.protected long replaceValue(V newValue)
newValue
- the new value to associate with this entrypublic boolean equals(Object o)
public int hashCode()
public String toString()
protected void setPrevPtr(LruHashMap.Entry<K,V> prevPtr)
prevPtr
- previous entryprotected LruHashMap.Entry<K,V> getPrevPtr()
protected void setNextPtr(LruHashMap.Entry<K,V> nextPtr)
nextPtr
- next entryprotected LruHashMap.Entry<K,V> getNextPtr()
Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.