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:
java.io.Serializable
,java.util.concurrent.ConcurrentMap<K,V>
,java.util.Map<K,V>
public class VeniceConcurrentHashMap<K,V> extends java.util.concurrent.ConcurrentHashMap<K,V>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
java.util.concurrent.ConcurrentHashMap.KeySetView<K extends java.lang.Object,V extends java.lang.Object>
-
-
Constructor Summary
Constructors Constructor Description VeniceConcurrentHashMap()
VeniceConcurrentHashMap(int initialCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
computeIfAbsent(K key, java.util.function.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
-
-
-
-
Method Detail
-
computeIfAbsent
public V computeIfAbsent(K key, java.util.function.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.
-
-