org.terracotta.collections.chm
Class SelectableConcurrentHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.terracotta.collections.chm.ConcurrentHashMap<K,V>
          extended by org.terracotta.collections.chm.SelectableConcurrentHashMap<K,V>
All Implemented Interfaces:
Serializable, ConcurrentMap<K,V>, Map<K,V>

public class SelectableConcurrentHashMap<K,V>
extends ConcurrentHashMap<K,V>

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
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.terracotta.collections.chm.ConcurrentHashMap
ConcurrentHashMap.HashEntry<K,V>
 
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()
           
SelectableConcurrentHashMap(int initialCapacity, float loadFactor, int concurrency)
           
 
Method Summary
 Map.Entry<K,V> getRandomEntry()
           
 Map.Entry<K,V> getRandomLocalEntry()
           
 ConcurrentHashMap.HashEntry<K,V> putReturnHashEntry(K key, V newValue)
           
 ConcurrentHashMap.HashEntry<K,V> removeReturnHashEntry(Object key)
           
 ConcurrentHashMap.HashEntry<K,V> removeReturnHashEntry(Object key, Object value)
           
 ConcurrentHashMap.HashEntry<K,V> replaceReturnHashEntry(K key, V newValue)
           
 ConcurrentHashMap.HashEntry<K,V> replaceReturnHashEntry(K key, V oldValue, V newValue)
           
 boolean replaceUsingReferenceEquality(K key, V oldValue, V newValue)
          Similar to ConcurrentHashMap.replace(Object, Object, Object), only difference is that it uses reference equality instead of object equality when comparing the oldValue and newValue
 
Methods inherited from class org.terracotta.collections.chm.ConcurrentHashMap
clear, contains, containsKey, containsValue, elements, entrySet, get, hash, isEmpty, keys, keySet, put, putAll, putIfAbsent, remove, remove, replace, replace, size, values
 
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

SelectableConcurrentHashMap

public SelectableConcurrentHashMap()

SelectableConcurrentHashMap

public SelectableConcurrentHashMap(int initialCapacity,
                                   float loadFactor,
                                   int concurrency)
Method Detail

getRandomEntry

public Map.Entry<K,V> getRandomEntry()

getRandomLocalEntry

public Map.Entry<K,V> getRandomLocalEntry()

replaceUsingReferenceEquality

public boolean replaceUsingReferenceEquality(K key,
                                             V oldValue,
                                             V newValue)
Similar to ConcurrentHashMap.replace(Object, Object, Object), only difference is that it uses reference equality instead of object equality when comparing the oldValue and newValue

Throws:
NullPointerException - if any of the arguments are null

removeReturnHashEntry

public ConcurrentHashMap.HashEntry<K,V> removeReturnHashEntry(Object key)

removeReturnHashEntry

public ConcurrentHashMap.HashEntry<K,V> removeReturnHashEntry(Object key,
                                                              Object value)

replaceReturnHashEntry

public ConcurrentHashMap.HashEntry<K,V> replaceReturnHashEntry(K key,
                                                               V oldValue,
                                                               V newValue)

putReturnHashEntry

public ConcurrentHashMap.HashEntry<K,V> putReturnHashEntry(K key,
                                                           V newValue)

replaceReturnHashEntry

public ConcurrentHashMap.HashEntry<K,V> replaceReturnHashEntry(K key,
                                                               V newValue)


Copyright © 2010 Terracotta, Inc.. All Rights Reserved.