K - the type of keys maintained by this mapV - the type of mapped valuespublic class OffHeapHashMap<K,V> extends AbstractMap<K,V> implements MapInternals, StorageEngine.Owner, HashingMap<K,V>
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.
| Modifier and Type | Class and Description |
|---|---|
protected class |
OffHeapHashMap.EncodingIterator |
protected class |
OffHeapHashMap.EncodingSet |
protected class |
OffHeapHashMap.EntryIterator |
protected class |
OffHeapHashMap.EntrySet |
protected class |
OffHeapHashMap.HashIterator<T> |
protected class |
OffHeapHashMap.KeyIterator |
protected class |
OffHeapHashMap.KeySet |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
protected static int |
ENCODING |
protected static int |
ENTRY_BIT_SHIFT |
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 static int |
KEY_HASHCODE |
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_REMOVED |
protected static int |
STATUS_USED |
protected StorageEngine<? super K,? super V> |
storageEngine |
protected PageSource |
tableSource |
| Modifier | Constructor and Description |
|---|---|
|
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. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
added(int position,
IntBuffer entry) |
void |
clear() |
MetadataTuple<V> |
computeIfAbsentWithMetadata(K key,
Function<? super K,? extends MetadataTuple<V>> mappingFunction) |
MetadataTuple<V> |
computeIfPresentWithMetadata(K key,
BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction) |
MetadataTuple<V> |
computeWithMetadata(K key,
BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction) |
boolean |
containsKey(Object key) |
protected Set<Long> |
createEncodingSet() |
protected Set<Map.Entry<K,V>> |
createEntrySet() |
protected Set<K> |
createKeySet() |
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) |
protected void |
freePendingTables() |
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(int position,
IntBuffer entry) |
protected int |
indexFor(int hash) |
protected static int |
indexFor(int hash,
IntBuffer table) |
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(int entryStatus) |
protected static boolean |
isRemoved(IntBuffer entry) |
protected static boolean |
isTerminating(int entryStatus) |
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() |
protected static long |
readLong(int[] array,
int offset) |
protected static long |
readLong(IntBuffer entry,
int offset) |
V |
remove(Object key) |
Map<K,V> |
removeAllWithHash(int hash)
Remove all keys having a specific hashcode.
|
protected void |
removeAtTableOffset(int offset,
boolean shrink) |
protected void |
removed(int position,
IntBuffer entry) |
protected boolean |
removeMapping(Object o) |
boolean |
removeNoReturn(Object key) |
protected void |
shrinkTable() |
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(int position,
IntBuffer entry) |
boolean |
updateEncoding(int hash,
long oldEncoding,
long newEncoding,
long mask) |
Lock |
writeLock() |
clone, containsValue, equals, hashCode, isEmpty, putAll, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, valuesprotected static final int ENTRY_SIZE
int unitsprotected static final int ENTRY_BIT_SHIFT
protected static final int STATUS
protected static final int KEY_HASHCODE
protected static final int ENCODING
protected static final int STATUS_USED
protected static final int STATUS_REMOVED
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
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 valuespublic 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 sizepublic 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)
public int size()
public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public Long getEncodingForHashAndBinary(int hash, ByteBuffer binaryKey)
getEncodingForHashAndBinary in interface StorageEngine.Ownerpublic long installMappingForHashAndEncoding(int pojoHash,
ByteBuffer offheapBinaryKey,
ByteBuffer offheapBinaryValue,
int metadata)
installMappingForHashAndEncoding in interface StorageEngine.Ownerpublic V fill(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic Map<K,V> removeAllWithHash(int hash)
HashingMapremoveAllWithHash in interface HashingMap<K,V>hash - the hashcode of the keys to be removed.Map containing the removed mappings.public boolean removeNoReturn(Object key)
public void clear()
public void destroy()
public final Set<Long> encodingSet()
encodingSet in interface StorageEngine.Ownerprotected static boolean isPresent(IntBuffer entry)
protected static boolean isAvailable(IntBuffer entry)
protected static boolean isTerminating(IntBuffer entry)
protected static boolean isTerminating(int entryStatus)
protected static boolean isRemoved(IntBuffer entry)
protected static boolean isRemoved(int entryStatus)
protected static long readLong(int[] array,
int offset)
protected static long readLong(IntBuffer entry, int offset)
protected int indexFor(int hash)
protected static int indexFor(int hash,
IntBuffer table)
protected boolean tryIncreaseReprobe()
protected void shrinkTable()
protected static int spread(int hash)
protected void freePendingTables()
protected boolean removeMapping(Object o)
public boolean evict(int index,
boolean shrink)
evict in interface StorageEngine.Ownerprotected void removeAtTableOffset(int offset,
boolean shrink)
protected V getAtTableOffset(int offset)
public Integer getSlotForHashAndEncoding(int hash, long encoding, long mask)
getSlotForHashAndEncoding in interface StorageEngine.Ownerpublic boolean updateEncoding(int hash,
long oldEncoding,
long newEncoding,
long mask)
updateEncoding in interface StorageEngine.Ownerprotected void added(int position,
IntBuffer entry)
protected void hit(int position,
IntBuffer entry)
protected void removed(int position,
IntBuffer entry)
protected void updated(int position,
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()
public MetadataTuple<V> computeWithMetadata(K key, BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction)
public MetadataTuple<V> computeIfAbsentWithMetadata(K key, Function<? super K,? extends MetadataTuple<V>> mappingFunction)
public MetadataTuple<V> computeIfPresentWithMetadata(K key, BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction)
Copyright © 2015–2024. All rights reserved.