Class MappedPool<K,V,E extends Exception>
- java.lang.Object
-
- com.apple.foundationdb.record.provider.common.MappedPool<K,V,E>
-
- Type Parameters:
K
- keyV
- value type to be pooledE
- exception that can be throw, must extend Exception
@API(EXPERIMENTAL) public class MappedPool<K,V,E extends Exception> extends Object
MappedPool Class Attempts to reuse objects organized by keys. This class can be used for objects that require thread safety but our expensive to create. The number of keys in the ConcurrentHashMap are unbounded but the queue for each key is bounded to 64. Examples include Ciphers and Compressors
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MappedPool.MappedPoolProvider<K,V,E extends Exception>
Function with Exceptions to provide the pool.
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_MAX_ENTRIES
protected static int
DEFAULT_POOL_SIZE
protected Callable<Queue<V>>
loader
protected com.google.common.cache.Cache<K,Queue<V>>
pool
-
Constructor Summary
Constructors Constructor Description MappedPool(MappedPool.MappedPoolProvider<K,V,E> mappedPoolProvider)
MappedPool(MappedPool.MappedPoolProvider<K,V,E> mappedPoolProvider, int poolSize)
MappedPool(MappedPool.MappedPoolProvider<K,V,E> mappedPoolProvider, int defaultPoolSize, int maxEntries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<K>
getKeys()
int
getPoolSize(K key)
Pool size for the key.boolean
offer(K key, V value)
Offer a key with a value knowing that the queue is bounded and might not accept the offer.V
poll(K key)
-
-
-
Field Detail
-
DEFAULT_POOL_SIZE
protected static final int DEFAULT_POOL_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_MAX_ENTRIES
protected static final int DEFAULT_MAX_ENTRIES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MappedPool
public MappedPool(MappedPool.MappedPoolProvider<K,V,E> mappedPoolProvider)
-
MappedPool
public MappedPool(MappedPool.MappedPoolProvider<K,V,E> mappedPoolProvider, int poolSize)
-
MappedPool
public MappedPool(MappedPool.MappedPoolProvider<K,V,E> mappedPoolProvider, int defaultPoolSize, int maxEntries)
-
-
Method Detail
-
offer
public boolean offer(@Nonnull K key, @Nonnull V value)
Offer a key with a value knowing that the queue is bounded and might not accept the offer.- Parameters:
key
- keyvalue
- value offered- Returns:
- boolean if offer was added to pool
-
getPoolSize
public int getPoolSize(K key)
Pool size for the key.- Parameters:
key
- key- Returns:
- size of pool
-
-