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:
ConcurrentMap<K,V>, ReadWriteLock, 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() and writeLock()
methods such that they return the correct locks under which read and write
operations must occur.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected classprotected classprotected classNested classes/interfaces inherited from class OffHeapHashMap
OffHeapHashMap.DirectEntry, OffHeapHashMap.EncodingIterator, OffHeapHashMap.EncodingSet, OffHeapHashMap.EntryIterator, OffHeapHashMap.EntrySet, OffHeapHashMap.HashIterator<T>, OffHeapHashMap.KeyIterator, OffHeapHashMap.KeySet, OffHeapHashMap.PendingPageNested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields inherited from class 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
ConstructorsConstructorDescriptionAbstractLockedOffHeapHashMap(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
Modifier and TypeMethodDescriptionvoidclear()computeIfAbsentWithMetadata(K key, Function<? super K, ? extends MetadataTuple<V>> mappingFunction) computeIfPresentWithMetadata(K key, BiFunction<? super K, ? super MetadataTuple<V>, ? extends MetadataTuple<V>> remappingFunction) computeWithMetadata(K key, BiFunction<? super K, ? super MetadataTuple<V>, ? extends MetadataTuple<V>> remappingFunction) booleancontainsKey(Object key) voiddestroy()booleanevict(int index, boolean shrink) Associates the specified value with the specified key in this map.getAndSetMetadata(Object key, int mask, int values) getEncodingForHashAndBinary(int hash, ByteBuffer binaryKey) getMetadata(Object key, int mask) getValueAndSetMetadata(Object key, int mask, int values) longinstallMappingForHashAndEncoding(int pojoHash, ByteBuffer offheapBinaryKey, ByteBuffer offheapBinaryValue, int metadata) putIfAbsent(K key, V value) abstract LockreadLock()booleanremoveAllWithHash(int hash) Remove all keys having a specific hashcode.protected booleanbooleanremoveNoReturn(Object key) booleanbooleanshrink()intsize()abstract LockMethods inherited from class 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, updateEncodingMethods inherited from class AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll, toString, valuesMethods inherited from interface ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAllMethods inherited from interface Map
containsValue, entrySet, equals, hashCode, isEmpty, keySet, putAll, valuesMethods inherited from interface MapInternals
getAllocatedMemory, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getTableCapacity, getUsedSlotCount, getVitalMemory
-
Constructor Details
-
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 Details
-
size
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classOffHeapHashMap<K,V>
-
get
-
getEncodingForHashAndBinary
- Specified by:
getEncodingForHashAndBinaryin interfaceStorageEngine.Owner- Overrides:
getEncodingForHashAndBinaryin classOffHeapHashMap<K,V>
-
installMappingForHashAndEncoding
public long installMappingForHashAndEncoding(int pojoHash, ByteBuffer offheapBinaryKey, ByteBuffer offheapBinaryValue, int metadata) - Specified by:
installMappingForHashAndEncodingin interfaceStorageEngine.Owner- Overrides:
installMappingForHashAndEncodingin classOffHeapHashMap<K,V>
-
put
-
put
-
fill
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).
-
fill
-
remove
-
removeNoReturn
- Specified by:
removeNoReturnin interfaceSegment<K,V> - Overrides:
removeNoReturnin classOffHeapHashMap<K,V>
-
clear
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
remove
-
replace
-
replace
-
getMetadata
- Specified by:
getMetadatain interfaceSegment<K,V> - Overrides:
getMetadatain classOffHeapHashMap<K,V>
-
getAndSetMetadata
- Specified by:
getAndSetMetadatain interfaceSegment<K,V> - Overrides:
getAndSetMetadatain classOffHeapHashMap<K,V>
-
getValueAndSetMetadata
- Specified by:
getValueAndSetMetadatain interfaceSegment<K,V> - Overrides:
getValueAndSetMetadatain classOffHeapHashMap<K,V>
-
removeMapping
- Overrides:
removeMappingin classOffHeapHashMap<K,V>
-
evict
public boolean evict(int index, boolean shrink) - Specified by:
evictin interfaceStorageEngine.Owner- Overrides:
evictin classOffHeapHashMap<K,V>
-
createEntrySet
- Overrides:
createEntrySetin classOffHeapHashMap<K,V>
-
createKeySet
- Overrides:
createKeySetin classOffHeapHashMap<K,V>
-
destroy
-
shrink
-
readLock
- Specified by:
readLockin interfaceReadWriteLock- Overrides:
readLockin classOffHeapHashMap<K,V>
-
writeLock
- Specified by:
writeLockin interfaceReadWriteLock- Overrides:
writeLockin classOffHeapHashMap<K,V>
-
computeWithMetadata
public MetadataTuple<V> computeWithMetadata(K key, 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, 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, BiFunction<? super K, ? super MetadataTuple<V>, ? extends MetadataTuple<V>> remappingFunction) - Specified by:
computeIfPresentWithMetadatain interfaceSegment<K,V> - Overrides:
computeIfPresentWithMetadatain classOffHeapHashMap<K,V>
-
removeAllWithHash
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.
-