Package org.terracotta.offheapstore
Class AbstractLockedOffHeapHashMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.terracotta.offheapstore.OffHeapHashMap<K,V>
-
- org.terracotta.offheapstore.AbstractLockedOffHeapHashMap<K,V>
-
- Type Parameters:
K- the type of keys maintained by this mapV- the type of mapped values
- All Implemented Interfaces:
java.util.concurrent.ConcurrentMap<K,V>,java.util.concurrent.locks.ReadWriteLock,java.util.Map<K,V>,HashingMap<K,V>,MapInternals,Segment<K,V>,StorageEngine.Owner
- Direct Known Subclasses:
AbstractOffHeapClockCache,AbstractPersistentLockedOffHeapHashMap,ReadWriteLockedOffHeapHashMap,WriteLockedOffHeapHashMap
public abstract class AbstractLockedOffHeapHashMap<K,V> extends OffHeapHashMap<K,V> implements Segment<K,V>
An abstract locked off-heap map.Subclasses must implement the
readLock()andwriteLock()methods such that they return the correct locks under which read and write operations must occur.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractLockedOffHeapHashMap.LockedEntryIteratorprotected classAbstractLockedOffHeapHashMap.LockedEntrySetprotected classAbstractLockedOffHeapHashMap.LockedKeyIteratorprotected classAbstractLockedOffHeapHashMap.LockedKeySet-
Nested classes/interfaces inherited from class org.terracotta.offheapstore.OffHeapHashMap
OffHeapHashMap.DirectEntry, OffHeapHashMap.EncodingIterator, OffHeapHashMap.EncodingSet, OffHeapHashMap.EntryIterator, OffHeapHashMap.EntrySet, OffHeapHashMap.HashIterator<T>, OffHeapHashMap.KeyIterator, OffHeapHashMap.KeySet, OffHeapHashMap.PendingPage
-
-
Field Summary
-
Fields inherited from class org.terracotta.offheapstore.OffHeapHashMap
ENCODING, ENTRY_BIT_SHIFT, ENTRY_SIZE, hashtable, hashTablePage, KEY_HASHCODE, modCount, removedSlots, reprobeLimit, RESERVED_STATUS_BITS, size, STATUS, STATUS_REMOVED, STATUS_USED, storageEngine, tableSource
-
-
Constructor Summary
Constructors Constructor Description AbstractLockedOffHeapHashMap(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine)AbstractLockedOffHeapHashMap(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine, int tableSize)AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine)AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, boolean bootstrap)AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize)AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize, boolean bootstrap)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclear()MetadataTuple<V>computeIfAbsentWithMetadata(K key, java.util.function.Function<? super K,? extends MetadataTuple<V>> mappingFunction)MetadataTuple<V>computeIfPresentWithMetadata(K key, java.util.function.BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction)MetadataTuple<V>computeWithMetadata(K key, java.util.function.BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction)booleancontainsKey(java.lang.Object key)protected java.util.Set<java.util.Map.Entry<K,V>>createEntrySet()protected java.util.Set<K>createKeySet()voiddestroy()booleanevict(int index, boolean shrink)Vfill(K key, V value)Associates the specified value with the specified key in this map.Vfill(K key, V value, int metadata)Vget(java.lang.Object key)java.lang.IntegergetAndSetMetadata(java.lang.Object key, int mask, int values)java.lang.LonggetEncodingForHashAndBinary(int hash, java.nio.ByteBuffer binaryKey)java.lang.IntegergetMetadata(java.lang.Object key, int mask)VgetValueAndSetMetadata(java.lang.Object key, int mask, int values)longinstallMappingForHashAndEncoding(int pojoHash, java.nio.ByteBuffer offheapBinaryKey, java.nio.ByteBuffer offheapBinaryValue, int metadata)Vput(K key, V value)Vput(K key, V value, int metadata)VputIfAbsent(K key, V value)abstract java.util.concurrent.locks.LockreadLock()Vremove(java.lang.Object key)booleanremove(java.lang.Object key, java.lang.Object value)java.util.Map<K,V>removeAllWithHash(int hash)Remove all keys having a specific hashcode.protected booleanremoveMapping(java.lang.Object o)booleanremoveNoReturn(java.lang.Object key)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)booleanshrink()intsize()abstract java.util.concurrent.locks.LockwriteLock()-
Methods inherited from class org.terracotta.offheapstore.OffHeapHashMap
added, createEncodingSet, encodingSet, entrySet, fill, freePendingTables, getAllocatedMemory, getAtTableOffset, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getEntryAtTableOffset, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getSlotForHashAndEncoding, getStorageEngine, getTableCapacity, getUsedSlotCount, getVitalMemory, hit, indexFor, indexFor, isAvailable, isPresent, isRemoved, isRemoved, isTerminating, isTerminating, isThiefForTableAllocations, keySet, readLong, readLong, removeAtTableOffset, removed, shrinkTable, spread, storageEngineFailure, tableExpansionFailure, tryIncreaseReprobe, updated, updateEncoding
-
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
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Methods inherited from interface java.util.Map
containsValue, entrySet, equals, hashCode, isEmpty, keySet, putAll, values
-
Methods inherited from interface org.terracotta.offheapstore.MapInternals
getAllocatedMemory, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getTableCapacity, getUsedSlotCount, getVitalMemory
-
-
-
-
Constructor Detail
-
AbstractLockedOffHeapHashMap
public AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine)
-
AbstractLockedOffHeapHashMap
public AbstractLockedOffHeapHashMap(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine)
-
AbstractLockedOffHeapHashMap
public AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, boolean bootstrap)
-
AbstractLockedOffHeapHashMap
public AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize)
-
AbstractLockedOffHeapHashMap
public AbstractLockedOffHeapHashMap(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine, int tableSize)
-
AbstractLockedOffHeapHashMap
public AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize, boolean bootstrap)
-
-
Method Detail
-
size
public int size()
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<K,V>- Overrides:
containsKeyin classOffHeapHashMap<K,V>
-
get
public V get(java.lang.Object key)
-
getEncodingForHashAndBinary
public java.lang.Long getEncodingForHashAndBinary(int hash, java.nio.ByteBuffer binaryKey)- Specified by:
getEncodingForHashAndBinaryin interfaceStorageEngine.Owner- Overrides:
getEncodingForHashAndBinaryin classOffHeapHashMap<K,V>
-
installMappingForHashAndEncoding
public long installMappingForHashAndEncoding(int pojoHash, java.nio.ByteBuffer offheapBinaryKey, java.nio.ByteBuffer offheapBinaryValue, int metadata)- Specified by:
installMappingForHashAndEncodingin interfaceStorageEngine.Owner- Overrides:
installMappingForHashAndEncodingin classOffHeapHashMap<K,V>
-
fill
public V fill(K key, V value)
Description copied from class:OffHeapHashMapAssociates the specified value with the specified key in this map. If the map does not contain a mapping for the key, the new mapping is only installed if there is room. If the map previously contained a mapping for the key, the old value is replaced by the specified value even if this results in a failure or eviction.- Specified by:
fillin interfaceSegment<K,V>- Overrides:
fillin classOffHeapHashMap<K,V>- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key (irrespective of whether the value was successfully installed).
-
remove
public V remove(java.lang.Object key)
-
removeNoReturn
public boolean removeNoReturn(java.lang.Object key)
- Specified by:
removeNoReturnin interfaceSegment<K,V>- Overrides:
removeNoReturnin classOffHeapHashMap<K,V>
-
clear
public void clear()
-
remove
public boolean remove(java.lang.Object key, java.lang.Object value)
-
getMetadata
public java.lang.Integer getMetadata(java.lang.Object key, int mask)- Specified by:
getMetadatain interfaceSegment<K,V>- Overrides:
getMetadatain classOffHeapHashMap<K,V>
-
getAndSetMetadata
public java.lang.Integer getAndSetMetadata(java.lang.Object key, int mask, int values)- Specified by:
getAndSetMetadatain interfaceSegment<K,V>- Overrides:
getAndSetMetadatain classOffHeapHashMap<K,V>
-
getValueAndSetMetadata
public V getValueAndSetMetadata(java.lang.Object key, int mask, int values)
- Specified by:
getValueAndSetMetadatain interfaceSegment<K,V>- Overrides:
getValueAndSetMetadatain classOffHeapHashMap<K,V>
-
removeMapping
protected boolean removeMapping(java.lang.Object o)
- Overrides:
removeMappingin classOffHeapHashMap<K,V>
-
evict
public boolean evict(int index, boolean shrink)- Specified by:
evictin interfaceStorageEngine.Owner- Overrides:
evictin classOffHeapHashMap<K,V>
-
createEntrySet
protected java.util.Set<java.util.Map.Entry<K,V>> createEntrySet()
- Overrides:
createEntrySetin classOffHeapHashMap<K,V>
-
createKeySet
protected java.util.Set<K> createKeySet()
- Overrides:
createKeySetin classOffHeapHashMap<K,V>
-
destroy
public void destroy()
-
readLock
public abstract java.util.concurrent.locks.Lock readLock()
- Specified by:
readLockin interfacejava.util.concurrent.locks.ReadWriteLock- Overrides:
readLockin classOffHeapHashMap<K,V>
-
writeLock
public abstract java.util.concurrent.locks.Lock writeLock()
- Specified by:
writeLockin interfacejava.util.concurrent.locks.ReadWriteLock- Overrides:
writeLockin classOffHeapHashMap<K,V>
-
computeWithMetadata
public MetadataTuple<V> computeWithMetadata(K key, java.util.function.BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction)
- Specified by:
computeWithMetadatain interfaceSegment<K,V>- Overrides:
computeWithMetadatain classOffHeapHashMap<K,V>
-
computeIfAbsentWithMetadata
public MetadataTuple<V> computeIfAbsentWithMetadata(K key, java.util.function.Function<? super K,? extends MetadataTuple<V>> mappingFunction)
- Specified by:
computeIfAbsentWithMetadatain interfaceSegment<K,V>- Overrides:
computeIfAbsentWithMetadatain classOffHeapHashMap<K,V>
-
computeIfPresentWithMetadata
public MetadataTuple<V> computeIfPresentWithMetadata(K key, java.util.function.BiFunction<? super K,? super MetadataTuple<V>,? extends MetadataTuple<V>> remappingFunction)
- Specified by:
computeIfPresentWithMetadatain interfaceSegment<K,V>- Overrides:
computeIfPresentWithMetadatain classOffHeapHashMap<K,V>
-
removeAllWithHash
public java.util.Map<K,V> removeAllWithHash(int hash)
Description copied from interface:HashingMapRemove all keys having a specific hashcode.- Specified by:
removeAllWithHashin interfaceHashingMap<K,V>- Overrides:
removeAllWithHashin classOffHeapHashMap<K,V>- Parameters:
hash- the hashcode of the keys to be removed.- Returns:
- a
Mapcontaining the removed mappings.
-
-