org.h2.dev.cluster
Class ShardedMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.h2.dev.cluster.ShardedMap<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
java.util.Map<K,V>

public class ShardedMap<K,V>
extends java.util.AbstractMap<K,V>
implements java.util.Map<K,V>

A sharded map. It is typically split into multiple sub-maps that don't have overlapping keys.


Nested Class Summary
static interface ShardedMap.CountedMap<K,V>
          A map that can efficiently return the index of a key, and the key at a given index.
static interface ShardedMap.LargeMap
          A large map.
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
ShardedMap()
           
ShardedMap(DataType keyType)
           
 
Method Summary
 void addMap(java.util.Map<K,V> map, K min, K max)
          Add the given shard.
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 V get(java.lang.Object key)
           
 V put(K key, V value)
           
 int size()
           
 long sizeAsLong()
          The size of the map.
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, values
 

Constructor Detail

ShardedMap

public ShardedMap()

ShardedMap

public ShardedMap(DataType keyType)
Method Detail

addMap

public void addMap(java.util.Map<K,V> map,
                   K min,
                   K max)
Add the given shard.

Parameters:
map - the map
min - the lowest key, or null if no limit
max - the highest key, or null if no limit

size

public int size()
Specified by:
size in interface java.util.Map<K,V>
Overrides:
size in class java.util.AbstractMap<K,V>

sizeAsLong

public long sizeAsLong()
The size of the map.

Returns:
the size

put

public V put(K key,
             V value)
Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class java.util.AbstractMap<K,V>

get

public V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class java.util.AbstractMap<K,V>

entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V>
Specified by:
entrySet in class java.util.AbstractMap<K,V>