|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
net.sf.ehcache.store.chm.SelectableConcurrentHashMap
public class SelectableConcurrentHashMap
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Constructor Summary | |
---|---|
SelectableConcurrentHashMap(PoolAccessor poolAccessor,
boolean elementPinningEnabled,
int initialCapacity,
float loadFactor,
int concurrency,
long maximumSize,
RegisteredEventListeners cacheEventNotificationService)
|
Method Summary | |
---|---|
void |
clear()
Removes all of the mappings from this map. |
boolean |
contains(Object value)
Legacy method testing if some key maps into the specified value in this table. |
boolean |
containsKey(Object key)
Tests if the specified object is a key in this table. |
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value. |
protected net.sf.ehcache.store.chm.ConcurrentHashMap.Segment<Object,Element> |
createSegment(int initialCapacity,
float lf)
|
Enumeration<V> |
elements()
Returns an enumeration of the values in this table. |
Set<Map.Entry<Object,Element>> |
entrySet()
Returns a Set view of the mappings contained in this map. |
boolean |
evict()
|
V |
get(Object key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. |
Element[] |
getRandomValues(int size,
Object keyHint)
|
protected static int |
hash(int h)
Applies a supplemental hash function to a given hashCode, which defends against poor quality hash functions. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
boolean |
isPinned(Object key)
|
Enumeration<K> |
keys()
Returns an enumeration of the keys in this table. |
Set<Object> |
keySet()
Returns a Set view of the keys contained in this map. |
ReentrantReadWriteLock |
lockFor(Object key)
|
ReentrantReadWriteLock[] |
locks()
|
Set |
pinnedKeySet()
|
int |
pinnedSize()
|
Element |
put(Object key,
Element value)
Maps the specified key to the specified value in this table. |
Element |
put(Object key,
Element element,
long sizeOf)
|
void |
putAll(Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this one. |
Element |
putIfAbsent(Object key,
Element value)
|
Element |
putIfAbsent(Object key,
Element element,
long sizeOf)
|
int |
quickSize()
Returns the number of key-value mappings in this map without locking anything. |
void |
recalculateSize(Object key)
|
V |
remove(Object key)
Removes the key (and its corresponding value) from this map. |
boolean |
remove(Object key,
Object value)
|
V |
replace(K key,
V value)
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
void |
setMaxSize(long maxSize)
|
void |
setPinned(Object key,
boolean pinned)
|
int |
size()
Returns the number of key-value mappings in this map. |
Object |
storedObject(Element e)
Return an object of the kind which will be stored when the element is going to be inserted |
void |
unpinAll()
|
Collection<Element> |
values()
Returns a Collection view of the values contained in this map. |
Methods inherited from class java.util.AbstractMap |
---|
clone, equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Constructor Detail |
---|
public SelectableConcurrentHashMap(PoolAccessor poolAccessor, boolean elementPinningEnabled, int initialCapacity, float loadFactor, int concurrency, long maximumSize, RegisteredEventListeners cacheEventNotificationService)
Method Detail |
---|
public void setMaxSize(long maxSize)
public Element[] getRandomValues(int size, Object keyHint)
public Object storedObject(Element e)
e
- the element
public int quickSize()
public int size()
size
in interface Map<Object,Element>
public int pinnedSize()
public ReentrantReadWriteLock lockFor(Object key)
public ReentrantReadWriteLock[] locks()
public Element put(Object key, Element value)
The value can be retrieved by calling the get method with a key that is equal to the original key.
put
in interface Map<Object,Element>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key
public Element putIfAbsent(Object key, Element value)
putIfAbsent
in interface ConcurrentMap<Object,Element>
public Element put(Object key, Element element, long sizeOf)
public Element putIfAbsent(Object key, Element element, long sizeOf)
public void unpinAll()
public void setPinned(Object key, boolean pinned)
public boolean isPinned(Object key)
public Set<Object> keySet()
Set
view of the keys contained in this map.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. The set supports element
removal, which removes the corresponding mapping from this map,
via the Iterator.remove, Set.remove,
removeAll, retainAll, and clear
operations. It does not support the add or
addAll operations.
The view's iterator is a "weakly consistent" iterator
that will never throw ConcurrentModificationException
,
and guarantees to traverse elements as they existed upon
construction of the iterator, and may (but is not guaranteed to)
reflect any modifications subsequent to construction.
keySet
in interface Map<Object,Element>
public Collection<Element> values()
Collection
view of the values contained in this map.
The collection is backed by the map, so changes to the map are
reflected in the collection, and vice-versa. The collection
supports element removal, which removes the corresponding
mapping from this map, via the Iterator.remove,
Collection.remove, removeAll,
retainAll, and clear operations. It does not
support the add or addAll operations.
The view's iterator is a "weakly consistent" iterator
that will never throw ConcurrentModificationException
,
and guarantees to traverse elements as they existed upon
construction of the iterator, and may (but is not guaranteed to)
reflect any modifications subsequent to construction.
values
in interface Map<Object,Element>
public Set<Map.Entry<Object,Element>> entrySet()
Set
view of the mappings contained in this map.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. The set supports element
removal, which removes the corresponding mapping from the map,
via the Iterator.remove, Set.remove,
removeAll, retainAll, and clear
operations. It does not support the add or
addAll operations.
The view's iterator is a "weakly consistent" iterator
that will never throw ConcurrentModificationException
,
and guarantees to traverse elements as they existed upon
construction of the iterator, and may (but is not guaranteed to)
reflect any modifications subsequent to construction.
entrySet
in interface Map<Object,Element>
protected net.sf.ehcache.store.chm.ConcurrentHashMap.Segment<Object,Element> createSegment(int initialCapacity, float lf)
public boolean evict()
public void recalculateSize(Object key)
public Set pinnedKeySet()
protected static int hash(int h)
public boolean isEmpty()
isEmpty
in interface Map<K,V>
isEmpty
in class AbstractMap<K,V>
public V get(Object key)
null
if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key
k
to a value v
such that key.equals(k)
,
then this method returns v
; otherwise it returns
null
. (There can be at most one such mapping.)
get
in interface Map<K,V>
get
in class AbstractMap<K,V>
NullPointerException
- if the specified key is nullpublic boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
key
- possible key
NullPointerException
- if the specified key is nullpublic boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in class AbstractMap<K,V>
value
- value whose presence in this map is to be tested
NullPointerException
- if the specified value is nullpublic boolean contains(Object value)
containsValue(java.lang.Object)
, and exists solely to ensure
full compatibility with class Hashtable
,
which supported this method prior to introduction of the
Java Collections framework.
value
- a value to search for
NullPointerException
- if the specified value is nullpublic void putAll(Map<? extends K,? extends V> m)
putAll
in interface Map<K,V>
putAll
in class AbstractMap<K,V>
m
- mappings to be stored in this mappublic V remove(Object key)
remove
in interface Map<K,V>
remove
in class AbstractMap<K,V>
key
- the key that needs to be removed
NullPointerException
- if the specified key is nullpublic boolean remove(Object key, Object value)
remove
in interface ConcurrentMap<K,V>
NullPointerException
- if the specified key is nullpublic boolean replace(K key, V oldValue, V newValue)
replace
in interface ConcurrentMap<K,V>
NullPointerException
- if any of the arguments are nullpublic V replace(K key, V value)
replace
in interface ConcurrentMap<K,V>
NullPointerException
- if the specified key or value is nullpublic void clear()
clear
in interface Map<K,V>
clear
in class AbstractMap<K,V>
public Enumeration<K> keys()
keySet()
public Enumeration<V> elements()
values()
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |