类 ConcurrentLongHashMap<V>
java.lang.Object
org.apache.pulsar.common.util.collections.ConcurrentLongHashMap<V>
- 类型参数:
V-
Map from long to an Object.
The forEach method is specifically designed for single-threaded usage. When iterating over a map with concurrent writes, it becomes possible for new values to be either observed or not observed. There is no guarantee that if we write value1 and value2, and are able to see value2, then we will also see value1. In some cases, it is even possible to encounter two mappings with the same key, leading the keys method to return a List containing two identical keys.
It is crucial to understand that the results obtained from aggregate status methods such as keys and values are typically reliable only when the map is not undergoing concurrent updates from other threads. When concurrent updates are involved, the results of these methods reflect transient states that may be suitable for monitoring or estimation purposes, but not for program control.
Provides similar methods as a ConcurrentMap<long,Object> with 2 differences:
- No boxing/unboxing from long -> Long
- Open hash map with linear probing, no node allocations to store the values
The forEach method is specifically designed for single-threaded usage. When iterating over a map with concurrent writes, it becomes possible for new values to be either observed or not observed. There is no guarantee that if we write value1 and value2, and are able to see value2, then we will also see value1. In some cases, it is even possible to encounter two mappings with the same key, leading the keys method to return a List containing two identical keys.
It is crucial to understand that the results obtained from aggregate status methods such as keys and values are typically reliable only when the map is not undergoing concurrent updates from other threads. When concurrent updates are involved, the results of these methods reflect transient states that may be suitable for monitoring or estimation purposes, but not for program control.
-
嵌套类概要
嵌套类修饰符和类型类说明static classBuilder of ConcurrentLongHashMap.static interfaceProcessor for one key-value entry, where the key islong. -
构造器概要
构造器构造器说明已过时。ConcurrentLongHashMap(int expectedItems) 已过时。ConcurrentLongHashMap(int expectedItems, int concurrencyLevel) 已过时。ConcurrentLongHashMap(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor) -
方法概要
修饰符和类型方法说明longcapacity()voidclear()computeIfAbsent(long key, LongFunction<V> provider) booleancontainsKey(long key) voidforEach(ConcurrentLongHashMap.EntryProcessor<V> processor) Iterate over all the entries in the map and apply the processor function to each of them.get(long key) booleanisEmpty()keys()static <V> ConcurrentLongHashMap.Builder<V>putIfAbsent(long key, V value) remove(long key) booleanlongsize()values()
-
构造器详细资料
-
ConcurrentLongHashMap
已过时。 -
ConcurrentLongHashMap
已过时。 -
ConcurrentLongHashMap
已过时。 -
ConcurrentLongHashMap
public ConcurrentLongHashMap(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor)
-
-
方法详细资料
-
newBuilder
-
size
public long size() -
capacity
public long capacity() -
isEmpty
public boolean isEmpty() -
get
-
containsKey
public boolean containsKey(long key) -
put
-
putIfAbsent
-
computeIfAbsent
-
remove
-
remove
-
clear
public void clear() -
forEach
Iterate over all the entries in the map and apply the processor function to each of them.Warning: Do Not Guarantee Thread-Safety.
- 参数:
processor- the processor to apply to each entry
-
keys
- 返回:
- a new list of all keys (makes a copy)
-
values
-