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>

public class VeniceConcurrentHashMap<K,V> extends ConcurrentHashMap<K,V>
See Also:
  • Constructor Details

    • VeniceConcurrentHashMap

      public VeniceConcurrentHashMap()
    • VeniceConcurrentHashMap

      public VeniceConcurrentHashMap(int initialCapacity)
  • Method Details

    • computeIfAbsent

      public V computeIfAbsent(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 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 ConcurrentMap<K,V>
      Specified by:
      computeIfAbsent in interface Map<K,V>
      Overrides:
      computeIfAbsent in class ConcurrentHashMap<K,V>
      Parameters:
      key -
      mappingFunction -
      Returns: