Package org.apache.hadoop.hbase.util
Class SoftObjectPool<K,V>
java.lang.Object
org.apache.hadoop.hbase.util.ObjectPool<K,V>
org.apache.hadoop.hbase.util.SoftObjectPool<K,V>
A
SoftReference
based shared object pool. The objects are kept in soft references and
associated with keys which are identified by the equals
method. The objects are created
by ObjectFactory on demand. The object creation is expected to be lightweight, and the objects
may be excessively created and discarded. Thread safe.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.util.ObjectPool
ObjectPool.ObjectFactory<K,
V> -
Field Summary
Fields inherited from class org.apache.hadoop.hbase.util.ObjectPool
DEFAULT_CONCURRENCY_LEVEL, DEFAULT_INITIAL_CAPACITY, referenceCache, staleRefQueue
-
Constructor Summary
ConstructorDescriptionSoftObjectPool
(ObjectPool.ObjectFactory<K, V> objectFactory) SoftObjectPool
(ObjectPool.ObjectFactory<K, V> objectFactory, int initialCapacity) SoftObjectPool
(ObjectPool.ObjectFactory<K, V> objectFactory, int initialCapacity, int concurrencyLevel) -
Method Summary
Modifier and TypeMethodDescriptioncreateReference
(K key, V obj) Create a reference associated with the given objectgetReferenceKey
(Reference<V> ref) Get key of the given referenceMethods inherited from class org.apache.hadoop.hbase.util.ObjectPool
get, purge, size
-
Constructor Details
-
SoftObjectPool
-
SoftObjectPool
-
SoftObjectPool
public SoftObjectPool(ObjectPool.ObjectFactory<K, V> objectFactory, int initialCapacity, int concurrencyLevel)
-
-
Method Details
-
createReference
Description copied from class:ObjectPool
Create a reference associated with the given object- Specified by:
createReference
in classObjectPool<K,
V> - Parameters:
key
- the key to store in the referenceobj
- the object to associate with- Returns:
- the reference instance
-
getReferenceKey
Description copied from class:ObjectPool
Get key of the given reference- Specified by:
getReferenceKey
in classObjectPool<K,
V> - Parameters:
ref
- The reference- Returns:
- key of the reference
-