@InterfaceAudience.Private public class CollectionUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
CollectionUtils.IOExceptionSupplier<V>
A supplier that throws IOException when get.
|
Constructor and Description |
---|
CollectionUtils() |
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,
CollectionUtils.IOExceptionSupplier<V> supplier)
In HBASE-16648 we found that ConcurrentHashMap.get is much faster than computeIfAbsent if the
value already exists.
|
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, CollectionUtils.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–2019 Cloudera. All rights reserved.