Class 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>
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • 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 exists ConcurrentHashMap.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
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • VeniceConcurrentHashMap

        public VeniceConcurrentHashMap()
      • VeniceConcurrentHashMap

        public VeniceConcurrentHashMap​(int initialCapacity)
    • 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 exists ConcurrentHashMap.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 interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        computeIfAbsent in interface java.util.Map<K,​V>
        Overrides:
        computeIfAbsent in class java.util.concurrent.ConcurrentHashMap<K,​V>
        Parameters:
        key -
        mappingFunction -
        Returns: