|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
org.terracotta.offheapstore.OffHeapHashMap<K,V>
K - the type of keys maintained by this mapV - the type of mapped valuespublic class OffHeapHashMap<K,V>
A hash-table implementation whose table is stored in an NIO direct buffer.
The map stores keys and values encoded as integers, in an open-addressed linear-reprobing hashtable. Entries are 16-bytes wide, and consist of:
int status markerint cached key hashcodelong {key:value} representationStorageEngine
instance provided at construction time.
This Map implementation is not thread-safe and does not support null
keys or values.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
protected static int |
ENTRY_SIZE
Size of a table entry in primitive int units |
protected IntBuffer |
hashtable
The current hash-table. |
protected Page |
hashTablePage
|
protected int |
modCount
|
protected int |
removedSlots
|
protected int |
reprobeLimit
|
static int |
RESERVED_STATUS_BITS
|
protected int |
size
|
protected static int |
STATUS
|
protected static int |
STATUS_USED
|
protected StorageEngine<? super K,? super V> |
storageEngine
|
protected PageSource |
tableSource
|
| Constructor Summary | |
|---|---|
|
OffHeapHashMap(PageSource source,
boolean tableAllocationsSteal,
StorageEngine<? super K,? super V> storageEngine)
|
|
OffHeapHashMap(PageSource source,
boolean tableAllocationsSteal,
StorageEngine<? super K,? super V> storageEngine,
int tableSize)
|
protected |
OffHeapHashMap(PageSource source,
boolean tableAllocationsSteal,
StorageEngine<? super K,? super V> storageEngine,
int tableSize,
boolean bootstrap)
|
|
OffHeapHashMap(PageSource source,
StorageEngine<? super K,? super V> storageEngine)
Construct an instance using a custom BufferSource for the
hashtable. |
|
OffHeapHashMap(PageSource source,
StorageEngine<? super K,? super V> storageEngine,
boolean bootstrap)
|
|
OffHeapHashMap(PageSource source,
StorageEngine<? super K,? super V> storageEngine,
int tableSize)
Construct an instance using a custom BufferSource for the
hashtable and a custom initial table size. |
| Method Summary | |
|---|---|
protected void |
added(IntBuffer entry)
|
void |
clear()
|
boolean |
containsKey(Object key)
|
void |
destroy()
|
Set<Long> |
encodingSet()
|
Set<Map.Entry<K,V>> |
entrySet()
|
boolean |
evict(int index,
boolean shrink)
|
V |
fill(K key,
V value)
Associates the specified value with the specified key in this map. |
V |
fill(K key,
V value,
int metadata)
|
protected V |
fill(K key,
V value,
int hash,
int[] newEntry,
int metadata)
|
V |
get(Object key)
|
long |
getAllocatedMemory()
|
Integer |
getAndSetMetadata(Object key,
int mask,
int values)
|
protected V |
getAtTableOffset(int offset)
|
long |
getDataAllocatedMemory()
|
long |
getDataOccupiedMemory()
|
long |
getDataSize()
|
long |
getDataVitalMemory()
|
Long |
getEncodingForHashAndBinary(int hash,
ByteBuffer binaryKey)
|
protected Map.Entry<K,V> |
getEntryAtTableOffset(int offset)
|
Integer |
getMetadata(Object key,
int mask)
|
long |
getOccupiedMemory()
|
long |
getRemovedSlotCount()
|
int |
getReprobeLength()
|
long |
getSize()
|
Integer |
getSlotForHashAndEncoding(int hash,
long encoding,
long mask)
|
StorageEngine<? super K,? super V> |
getStorageEngine()
|
long |
getTableCapacity()
|
long |
getUsedSlotCount()
|
V |
getValueAndSetMetadata(Object key,
int mask,
int values)
|
long |
getVitalMemory()
|
protected void |
hit(IntBuffer entry)
|
long |
installMappingForHashAndEncoding(int pojoHash,
ByteBuffer offheapBinaryKey,
ByteBuffer offheapBinaryValue,
int metadata)
|
protected static boolean |
isAvailable(IntBuffer entry)
|
protected static boolean |
isPresent(IntBuffer entry)
|
protected static boolean |
isRemoved(IntBuffer entry)
|
protected static boolean |
isTerminating(IntBuffer entry)
|
boolean |
isThiefForTableAllocations()
|
Set<K> |
keySet()
|
V |
put(K key,
V value)
|
V |
put(K key,
V value,
int metadata)
|
Lock |
readLock()
|
V |
remove(Object key)
|
protected void |
removeAtTableOffset(int offset,
boolean shrink)
|
protected void |
removed(IntBuffer entry)
|
protected boolean |
removeMapping(Object o)
|
boolean |
removeNoReturn(Object key)
|
int |
size()
|
protected static int |
spread(int hash)
|
protected void |
storageEngineFailure(Object failure)
|
protected void |
tableExpansionFailure(int start,
int length)
|
protected boolean |
tryIncreaseReprobe()
|
protected void |
updated(IntBuffer entry)
|
boolean |
updateEncoding(int hash,
long oldEncoding,
long newEncoding,
long mask)
|
Lock |
writeLock()
|
| Methods inherited from class java.util.AbstractMap |
|---|
clone, containsValue, equals, hashCode, isEmpty, putAll, toString, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final int ENTRY_SIZE
int units
protected static final int STATUS
protected static final int STATUS_USED
public static final int RESERVED_STATUS_BITS
protected final StorageEngine<? super K,? super V> storageEngine
protected final PageSource tableSource
protected volatile int size
protected volatile int modCount
protected int reprobeLimit
protected volatile IntBuffer hashtable
A list of: int[] {status, hashCode, encoding-high, encoding-low}
protected volatile Page hashTablePage
protected volatile int removedSlots
| Constructor Detail |
|---|
public OffHeapHashMap(PageSource source,
StorageEngine<? super K,? super V> storageEngine)
BufferSource for the
hashtable.
source - source for the hashtable allocationsstorageEngine - engine used to encode the keys and values
public OffHeapHashMap(PageSource source,
boolean tableAllocationsSteal,
StorageEngine<? super K,? super V> storageEngine)
public OffHeapHashMap(PageSource source,
StorageEngine<? super K,? super V> storageEngine,
boolean bootstrap)
public OffHeapHashMap(PageSource source,
StorageEngine<? super K,? super V> storageEngine,
int tableSize)
BufferSource for the
hashtable and a custom initial table size.
source - source for the hashtable allocationsstorageEngine - engine used to encode the keys and valuestableSize - the initial table size
public OffHeapHashMap(PageSource source,
boolean tableAllocationsSteal,
StorageEngine<? super K,? super V> storageEngine,
int tableSize)
protected OffHeapHashMap(PageSource source,
boolean tableAllocationsSteal,
StorageEngine<? super K,? super V> storageEngine,
int tableSize,
boolean bootstrap)
| Method Detail |
|---|
public int size()
size in interface Map<K,V>size in class AbstractMap<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public V get(Object key)
get in interface Map<K,V>get in class AbstractMap<K,V>
public Long getEncodingForHashAndBinary(int hash,
ByteBuffer binaryKey)
getEncodingForHashAndBinary in interface StorageEngine.Owner
public long installMappingForHashAndEncoding(int pojoHash,
ByteBuffer offheapBinaryKey,
ByteBuffer offheapBinaryValue,
int metadata)
installMappingForHashAndEncoding in interface StorageEngine.Owner
public Integer getMetadata(Object key,
int mask)
public Integer getAndSetMetadata(Object key,
int mask,
int values)
public V getValueAndSetMetadata(Object key,
int mask,
int values)
public V put(K key,
V value)
put in interface Map<K,V>put in class AbstractMap<K,V>
public V put(K key,
V value,
int metadata)
public V fill(K key,
V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified key
public V fill(K key,
V value,
int metadata)
protected final V fill(K key,
V value,
int hash,
int[] newEntry,
int metadata)
public V remove(Object key)
remove in interface Map<K,V>remove in class AbstractMap<K,V>public boolean removeNoReturn(Object key)
public void clear()
clear in interface Map<K,V>clear in class AbstractMap<K,V>public void destroy()
public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>entrySet in class AbstractMap<K,V>public Set<Long> encodingSet()
encodingSet in interface StorageEngine.Ownerpublic Set<K> keySet()
keySet in interface Map<K,V>keySet in class AbstractMap<K,V>protected static boolean isPresent(IntBuffer entry)
protected static boolean isAvailable(IntBuffer entry)
protected static boolean isTerminating(IntBuffer entry)
protected static boolean isRemoved(IntBuffer entry)
protected boolean tryIncreaseReprobe()
protected static int spread(int hash)
protected boolean removeMapping(Object o)
public boolean evict(int index,
boolean shrink)
evict in interface StorageEngine.Owner
protected void removeAtTableOffset(int offset,
boolean shrink)
protected V getAtTableOffset(int offset)
protected Map.Entry<K,V> getEntryAtTableOffset(int offset)
public Integer getSlotForHashAndEncoding(int hash,
long encoding,
long mask)
getSlotForHashAndEncoding in interface StorageEngine.Owner
public boolean updateEncoding(int hash,
long oldEncoding,
long newEncoding,
long mask)
updateEncoding in interface StorageEngine.Ownerprotected void added(IntBuffer entry)
protected void hit(IntBuffer entry)
protected void removed(IntBuffer entry)
protected void updated(IntBuffer entry)
protected void tableExpansionFailure(int start,
int length)
protected void storageEngineFailure(Object failure)
public long getSize()
getSize in interface MapInternalsgetSize in interface StorageEngine.Ownerpublic long getTableCapacity()
getTableCapacity in interface MapInternalspublic long getUsedSlotCount()
getUsedSlotCount in interface MapInternalspublic long getRemovedSlotCount()
getRemovedSlotCount in interface MapInternalspublic int getReprobeLength()
getReprobeLength in interface MapInternalspublic long getAllocatedMemory()
getAllocatedMemory in interface MapInternalspublic long getOccupiedMemory()
getOccupiedMemory in interface MapInternalspublic long getVitalMemory()
getVitalMemory in interface MapInternalspublic long getDataAllocatedMemory()
getDataAllocatedMemory in interface MapInternalspublic long getDataOccupiedMemory()
getDataOccupiedMemory in interface MapInternalspublic long getDataVitalMemory()
getDataVitalMemory in interface MapInternalspublic long getDataSize()
getDataSize in interface MapInternalspublic boolean isThiefForTableAllocations()
isThiefForTableAllocations in interface StorageEngine.Ownerpublic Lock readLock()
readLock in interface ReadWriteLockpublic Lock writeLock()
writeLock in interface ReadWriteLockpublic StorageEngine<? super K,? super V> getStorageEngine()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||