net.sf.ehcache.store.chm
Class SelectableConcurrentHashMap
java.lang.Object
net.sf.ehcache.store.chm.SelectableConcurrentHashMap
public class SelectableConcurrentHashMap
- extends Object
SelectableConcurrentHashMap subclasses a repackaged version of ConcurrentHashMap
ito allow efficient random sampling of the map values.
The random sampling technique involves randomly selecting a map Segment, and then
selecting a number of random entry chains from that segment.
- Author:
- Chris Dennis
Constructor Summary |
SelectableConcurrentHashMap(PoolAccessor poolAccessor,
boolean elementPinningEnabled,
int initialCapacity,
float loadFactor,
int concurrency,
long maximumSize,
RegisteredEventListeners cacheEventNotificationService)
|
SelectableConcurrentHashMap(PoolAccessor poolAccessor,
boolean elementPinningEnabled,
int concurrency,
long maximumSize,
RegisteredEventListeners cacheEventNotificationService)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DUMMY_PINNED_ELEMENT
protected static final Element DUMMY_PINNED_ELEMENT
SelectableConcurrentHashMap
public SelectableConcurrentHashMap(PoolAccessor poolAccessor,
boolean elementPinningEnabled,
int concurrency,
long maximumSize,
RegisteredEventListeners cacheEventNotificationService)
SelectableConcurrentHashMap
public SelectableConcurrentHashMap(PoolAccessor poolAccessor,
boolean elementPinningEnabled,
int initialCapacity,
float loadFactor,
int concurrency,
long maximumSize,
RegisteredEventListeners cacheEventNotificationService)
setMaxSize
public void setMaxSize(long maxSize)
getRandomValues
public Element[] getRandomValues(int size,
Object keyHint)
storedObject
public Object storedObject(Element e)
- Return an object of the kind which will be stored when
the element is going to be inserted
- Parameters:
e
- the element
- Returns:
- an object looking-alike the stored one
quickSize
public int quickSize()
- Returns the number of key-value mappings in this map without locking anything.
This may not give the exact element count as locking is avoided.
If the map contains more than Integer.MAX_VALUE elements, returns
Integer.MAX_VALUE.
- Returns:
- the number of key-value mappings in this map
isEmpty
public boolean isEmpty()
size
public int size()
pinnedSize
public int pinnedSize()
lockFor
public ReentrantReadWriteLock lockFor(Object key)
locks
public ReentrantReadWriteLock[] locks()
get
public Element get(Object key)
containsKey
public boolean containsKey(Object key)
containsValue
public boolean containsValue(Object value)
put
public Element put(Object key,
Element element,
long sizeOf)
putIfAbsent
public Element putIfAbsent(Object key,
Element element,
long sizeOf)
remove
public Element remove(Object key)
remove
public boolean remove(Object key,
Object value)
clear
public void clear()
unpinAll
public void unpinAll()
setPinned
public void setPinned(Object key,
boolean pinned)
isPinned
public boolean isPinned(Object key)
keySet
public Set<Object> keySet()
values
public Collection<Element> values()
entrySet
public Set<Map.Entry<Object,Element>> entrySet()
createSegment
protected SelectableConcurrentHashMap.Segment createSegment(int initialCapacity,
float lf)
evict
public boolean evict()
recalculateSize
public void recalculateSize(Object key)
pinnedKeySet
public Set pinnedKeySet()
segmentFor
protected final SelectableConcurrentHashMap.Segment segmentFor(int hash)
- Returns the segment that should be used for key with given hash
- Parameters:
hash
- the hash code for the key
- Returns:
- the segment
segments
protected final List<SelectableConcurrentHashMap.Segment> segments()
hash
protected static int hash(int h)
Copyright © 2003-2014 Terracotta, Inc.. All Rights Reserved.