パッケージ org.springframework.util
クラス ConcurrentReferenceHashMap<K,V>
java.lang.ObjectSE
java.util.AbstractMapSE<K,V>
org.springframework.util.ConcurrentReferenceHashMap<K,V>
- 型パラメーター:
K- キー型V- 値の型
- 実装されているすべてのインターフェース:
ConcurrentMapSE<K,,V> MapSE<K,V>
public class ConcurrentReferenceHashMap<K,V>
extends AbstractMapSE<K,V>
implements ConcurrentMapSE<K,V>
soft または keys と values の両方に弱い参照を使用する ConcurrentHashMapSE。 このクラスは、同時にアクセスしたときにパフォーマンスを向上させるために、Collections.synchronizedMap(new WeakHashMap<K, Reference<V>>()) の代替として使用できます。この実装は、null 値と null キーがサポートされていることを除いて、ConcurrentHashMapSE と同じ設計上の制約に従います。
注意 : 参照の使用は、マップに配置されたアイテムが後で利用可能になるという保証がないことを意味します。ガベージコレクターはいつでも参照を破棄する可能性があるため、不明なスレッドが静かにエントリを削除しているように見えることがあります。
明示的に指定されていない場合、この実装はソフトエントリ参照SEを使用します。
- 導入:
- 3.2
- 作成者:
- Phillip Webb, Juergen Hoeller, Brian Clozel
ネストされたクラスの要約
ネストされたクラス修飾子と型クラス説明protected static final class単一のマップエントリ。protected static interfaceマップに含まれるConcurrentReferenceHashMap.Entryへの参照。protected classReferencesを管理するために使用される戦略クラス。static enumこのマップでサポートされるさまざまな参照型。protected static enum実行できる再構築の種類。protected final class同時パフォーマンスを向上させるためにマップを分割するために使用される単一のセグメント。クラス java.util.AbstractMapSE から継承されたネストクラス / インターフェース
AbstractMap.SimpleEntrySE<KSE extends ObjectSE,VSE extends ObjectSE>, AbstractMap.SimpleImmutableEntrySE<KSE extends ObjectSE, VSE extends ObjectSE> コンストラクターの概要
コンストラクターコンストラクター説明新しいConcurrentReferenceHashMapインスタンスを作成します。ConcurrentReferenceHashMap(int initialCapacity) 新しいConcurrentReferenceHashMapインスタンスを作成します。ConcurrentReferenceHashMap(int initialCapacity, float loadFactor) 新しいConcurrentReferenceHashMapインスタンスを作成します。ConcurrentReferenceHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) 新しいConcurrentReferenceHashMapインスタンスを作成します。ConcurrentReferenceHashMap(int initialCapacity, float loadFactor, int concurrencyLevel, ConcurrentReferenceHashMap.ReferenceType referenceType) 新しいConcurrentReferenceHashMapインスタンスを作成します。ConcurrentReferenceHashMap(int initialCapacity, int concurrencyLevel) 新しいConcurrentReferenceHashMapインスタンスを作成します。ConcurrentReferenceHashMap(int initialCapacity, ConcurrentReferenceHashMap.ReferenceType referenceType) 新しいConcurrentReferenceHashMapインスタンスを作成します。メソッドのサマリー
修飾子と型メソッド説明protected static intcalculateShift(int minimumValue, int maximumValue) 指定された最大値と最小値の間の 2 のべき乗値を作成するために使用できるシフト値を計算します。voidclear()booleancontainsKey(ObjectSE key) protected ConcurrentReferenceHashMap<K,V>.ReferenceManager ConcurrentReferenceHashMap<K,を返すファクトリメソッド。V>.ReferenceManager SetSE<Map.EntrySE<K,V>> entrySet()protected int特定のオブジェクトのハッシュを取得し、追加のハッシュ関数を適用して衝突を減らします。protected final floatgetOrDefault(ObjectSE key, V defaultValue) protected final ConcurrentReferenceHashMap.Reference<K,V> getReference(ObjectSE key, ConcurrentReferenceHashMap.Restructure restructure) 指定されたkeyのConcurrentReferenceHashMap.ReferenceをConcurrentReferenceHashMap.Entryに返します。見つからない場合はnullを返します。protected final ConcurrentReferenceHashMap<K,V>.Segment getSegment(int index) protected final intbooleanisEmpty()voidガベージコレクションされ、参照されなくなったエントリを削除します。putIfAbsent(K key, V value) booleanbooleanintsize()クラス java.util.AbstractMapSE から継承されたメソッド
clone, containsValueSE, equalsSE, hashCode, keySet, putAllSE, toString, valuesインターフェース java.util.concurrent.ConcurrentMapSE から継承されたメソッド
computeSE, computeIfAbsentSE, computeIfPresentSE, forEachSE, mergeSE, replaceAllSE
コンストラクターの詳細
ConcurrentReferenceHashMap
public ConcurrentReferenceHashMap()新しいConcurrentReferenceHashMapインスタンスを作成します。ConcurrentReferenceHashMap
public ConcurrentReferenceHashMap(int initialCapacity) 新しいConcurrentReferenceHashMapインスタンスを作成します。- パラメーター:
initialCapacity- マップの初期容量
ConcurrentReferenceHashMap
public ConcurrentReferenceHashMap(int initialCapacity, float loadFactor) 新しいConcurrentReferenceHashMapインスタンスを作成します。- パラメーター:
initialCapacity- マップの初期容量loadFactor- 負荷率。テーブルごとの平均参照数がこの値を超えると、サイズ変更が試行されます
ConcurrentReferenceHashMap
public ConcurrentReferenceHashMap(int initialCapacity, int concurrencyLevel) 新しいConcurrentReferenceHashMapインスタンスを作成します。- パラメーター:
initialCapacity- マップの初期容量concurrencyLevel- 同時にマップに書き込むスレッドの予想数
ConcurrentReferenceHashMap
public ConcurrentReferenceHashMap(int initialCapacity, ConcurrentReferenceHashMap.ReferenceType referenceType) 新しいConcurrentReferenceHashMapインスタンスを作成します。- パラメーター:
initialCapacity- マップの初期容量referenceType- エントリに使用される参照型 (柔らかいか弱い)
ConcurrentReferenceHashMap
public ConcurrentReferenceHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) 新しいConcurrentReferenceHashMapインスタンスを作成します。- パラメーター:
initialCapacity- マップの初期容量loadFactor- 負荷率。テーブルごとの平均参照数がこの値を超えると、サイズ変更が試行されます。concurrencyLevel- 同時にマップに書き込むスレッドの予想数
ConcurrentReferenceHashMap
public ConcurrentReferenceHashMap(int initialCapacity, float loadFactor, int concurrencyLevel, ConcurrentReferenceHashMap.ReferenceType referenceType) 新しいConcurrentReferenceHashMapインスタンスを作成します。- パラメーター:
initialCapacity- マップの初期容量loadFactor- 負荷率。テーブルごとの平均参照数がこの値を超えると、サイズ変更が試行されます。concurrencyLevel- 同時にマップに書き込むスレッドの予想数referenceType- エントリに使用される参照型 (柔らかいか弱い)
メソッドの詳細
getLoadFactor
protected final float getLoadFactor()getSegmentsSize
protected final int getSegmentsSize()getSegment
createReferenceManager
ConcurrentReferenceHashMap<K,を返すファクトリメソッド。このメソッドは、各V>.ReferenceManager ConcurrentReferenceHashMap<K,に対して 1 回呼び出されます。V>.Segment - 戻り値:
- 新しい参照マネージャー
getHash
特定のオブジェクトのハッシュを取得し、追加のハッシュ関数を適用して衝突を減らします。この実装では、ConcurrentHashMapSE と同じ Wang/Jenkins アルゴリズムを使用します。サブクラスは、代替ハッシュを提供するためにオーバーライドできます。- パラメーター:
o- ハッシュするオブジェクト (null の可能性があります)- 戻り値:
- 結果のハッシュコード
get
getOrDefault
- 次で指定:
- インターフェース
ConcurrentMapSE<K,のV> getOrDefaultSE - 次で指定:
- インターフェース
MapSE<K,のV> getOrDefaultSE
containsKey
- 次で指定:
- インターフェース
MapSE<K,のV> containsKeySE - オーバーライド:
- クラス
AbstractMapSE<K,のV> containsKeySE
getReference
@Nullable protected final ConcurrentReferenceHashMap.Reference<K,V> getReference(@Nullable ObjectSE key, ConcurrentReferenceHashMap.Restructure restructure) 指定されたkeyのConcurrentReferenceHashMap.ReferenceをConcurrentReferenceHashMap.Entryに返します。見つからない場合はnullを返します。- パラメーター:
key- キー (nullにすることができます)restructure- この呼び出し中に許可される再構築の型- 戻り値:
- 参照。見つからない場合は
null
put
putIfAbsent
- 次で指定:
- インターフェース
ConcurrentMapSE<K,のV> putIfAbsentSE - 次で指定:
- インターフェース
MapSE<K,のV> putIfAbsentSE
remove
remove
replace
replace
clear
public void clear()purgeUnreferencedEntries
public void purgeUnreferencedEntries()ガベージコレクションされ、参照されなくなったエントリを削除します。通常の状況では、マップにアイテムが追加または削除されると、ガベージコレクションのエントリが自動的に削除されます。このメソッドはパージを強制するために使用でき、マップが頻繁に読み取られるが更新頻度が低い場合に役立ちます。size
public int size()isEmpty
public boolean isEmpty()entrySet
calculateShift
protected static int calculateShift(int minimumValue, int maximumValue) 指定された最大値と最小値の間の 2 のべき乗値を作成するために使用できるシフト値を計算します。- パラメーター:
minimumValue- 最小値maximumValue- 最大値- 戻り値:
- 計算されたシフト (
1 << shiftを使用して値を取得する)