Package org.apache.hadoop.hbase.util
Class ConcurrentMapUtils
java.lang.Object
org.apache.hadoop.hbase.util.ConcurrentMapUtils
Utility methods for dealing with Collections, including treating null collections as empty.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> V computeIfAbsent(ConcurrentMap<K, V> map, K key, Supplier<V> supplier) In HBASE-16648 we found that ConcurrentHashMap.get is much faster than computeIfAbsent if the value already exists.static <K,V> V computeIfAbsent(ConcurrentMap<K, V> map, K key, Supplier<V> supplier, Runnable actionIfAbsent) static <K,V> V computeIfAbsentEx(ConcurrentMap<K, V> map, K key, IOExceptionSupplier<V> supplier) In HBASE-16648 we found that ConcurrentHashMap.get is much faster than computeIfAbsent if the value already exists.
-
Constructor Details
-
ConcurrentMapUtils
public ConcurrentMapUtils()
-
-
Method Details
-
computeIfAbsent
In HBASE-16648 we found that ConcurrentHashMap.get is much faster than computeIfAbsent if the value already exists. Notice that the implementation does not guarantee that the supplier will only be executed once. -
computeIfAbsentEx
public static <K,V> V computeIfAbsentEx(ConcurrentMap<K, V> map, K key, IOExceptionSupplier<V> supplier) throws IOExceptionIn HBASE-16648 we found that ConcurrentHashMap.get is much faster than computeIfAbsent if the value already exists. So here we copy the implementation ofConcurrentMap.computeIfAbsent(Object, java.util.function.Function). It uses get and putIfAbsent to implement computeIfAbsent. And notice that the implementation does not guarantee that the supplier will only be executed once.- Throws:
IOException
-
computeIfAbsent
public static <K,V> V computeIfAbsent(ConcurrentMap<K, V> map, K key, Supplier<V> supplier, Runnable actionIfAbsent)
-