Class VeniceConcurrentHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.concurrent.ConcurrentHashMap<K,V>
com.linkedin.venice.utils.concurrent.VeniceConcurrentHashMap<K,V>
- All Implemented Interfaces:
Serializable
,ConcurrentMap<K,
,V> Map<K,
V>
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
ConcurrentHashMap.KeySetView<K extends Object,
V extends Object> Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncomputeIfAbsent
(K key, Function<? super K, ? extends V> mappingFunction) TODO: Remove this class once the code has completely migrated to JDK11+ The native `computeIfAbsent` function implemented in Java could have contention when the value already existsConcurrentHashMap.computeIfAbsent(Object, Function)
; the contention could become very bad when lots of threads are trying to "computeIfAbsent" on the same key, which is a known Java bug: https://bugs.openjdk.java.net/browse/JDK-8161372 This internal VeniceConcurrentHashMap mitigate such contention by trying to get the value first before invoking "computeIfAbsent", which brings great optimization if the major workload is trying to get the same key over and over again; however, we speculate that this optimization might not be ideal for the workload that most keys are unique, so be cautious about the workload before adopting the VeniceConcurrentHashMap.Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, compute, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
Methods inherited from class java.util.AbstractMap
clone
-
Constructor Details
-
VeniceConcurrentHashMap
public VeniceConcurrentHashMap() -
VeniceConcurrentHashMap
public VeniceConcurrentHashMap(int initialCapacity)
-
-
Method Details
-
computeIfAbsent
TODO: Remove this class once the code has completely migrated to JDK11+ The native `computeIfAbsent` function implemented in Java could have contention when the value already existsConcurrentHashMap.computeIfAbsent(Object, Function)
; the contention could become very bad when lots of threads are trying to "computeIfAbsent" on the same key, which is a known Java bug: https://bugs.openjdk.java.net/browse/JDK-8161372 This internal VeniceConcurrentHashMap mitigate such contention by trying to get the value first before invoking "computeIfAbsent", which brings great optimization if the major workload is trying to get the same key over and over again; however, we speculate that this optimization might not be ideal for the workload that most keys are unique, so be cautious about the workload before adopting the VeniceConcurrentHashMap.- Specified by:
computeIfAbsent
in interfaceConcurrentMap<K,
V> - Specified by:
computeIfAbsent
in interfaceMap<K,
V> - Overrides:
computeIfAbsent
in classConcurrentHashMap<K,
V> - Parameters:
key
-mappingFunction
-- Returns:
-