@InterfaceAudience.Private public class ConcurrentMapUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ConcurrentMapUtils.IOExceptionSupplier<V>
A supplier that throws IOException when get.
|
Constructor and Description |
---|
ConcurrentMapUtils() |
Modifier and Type | Method and Description |
---|---|
static <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,
ConcurrentMapUtils.IOExceptionSupplier<V> supplier)
In HBASE-16648 we found that ConcurrentHashMap.get is much faster than computeIfAbsent if the
value already exists.
|
public ConcurrentMapUtils()
public static <K,V> V computeIfAbsent(ConcurrentMap<K,V> map, K key, Supplier<V> supplier)
public static <K,V> V computeIfAbsentEx(ConcurrentMap<K,V> map, K key, ConcurrentMapUtils.IOExceptionSupplier<V> supplier) throws IOException
ConcurrentMap.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.IOException
public static <K,V> V computeIfAbsent(ConcurrentMap<K,V> map, K key, Supplier<V> supplier, Runnable actionIfAbsent)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.