org.webmacro.util
Class AbstractScalableMap

java.lang.Object
  extended byorg.webmacro.util.AbstractScalableMap
All Implemented Interfaces:
SimpleMap
Direct Known Subclasses:
ScalableIdentityMap, ScalableMap

public class AbstractScalableMap
extends java.lang.Object
implements SimpleMap

Reduce locking overhead for a map with few writers and many readers. Writes are five times more expensive than a SimpleMap, reads cost only slightly more. However, five readers can access the same value simultaneously, without blocking.
This is a generic implementation that uses instances of SimpleMap as real maps.


Field Summary
static int DEFAULT_FACTOR
           
 
Constructor Summary
AbstractScalableMap(int factor, SimpleMapFactory mapFactory)
          Create a new scalable map, that uses factor SimpleMaps.
AbstractScalableMap(SimpleMapFactory mapFactory)
           
 
Method Summary
 void clear()
           
 java.lang.Object get(java.lang.Object key)
          Get the value of 'key' back.
 void put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
          Ensure that the key does not appear in the map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FACTOR

public static final int DEFAULT_FACTOR
See Also:
Constant Field Values
Constructor Detail

AbstractScalableMap

public AbstractScalableMap(int factor,
                           SimpleMapFactory mapFactory)
Create a new scalable map, that uses factor SimpleMaps. SimpleMap object are created by mapFactory.

Parameters:
factor - number of SimpleMaps to create
mapFactory - object to create SimpleMap objects

AbstractScalableMap

public AbstractScalableMap(SimpleMapFactory mapFactory)
Method Detail

put

public void put(java.lang.Object key,
                java.lang.Object value)
Specified by:
put in interface SimpleMap

get

public java.lang.Object get(java.lang.Object key)
Description copied from interface: SimpleMap
Get the value of 'key' back. Returns null if no such key.

Specified by:
get in interface SimpleMap

remove

public java.lang.Object remove(java.lang.Object key)
Description copied from interface: SimpleMap
Ensure that the key does not appear in the map

Specified by:
remove in interface SimpleMap

clear

public void clear()
Specified by:
clear in interface SimpleMap