akka.util
Class SubclassifiedIndex<K,V>

java.lang.Object
  extended by akka.util.SubclassifiedIndex<K,V>
Direct Known Subclasses:
SubclassifiedIndex.Nonroot

public class SubclassifiedIndex<K,V>
extends java.lang.Object

Mutable index which respects sub-class relationships between keys:

- adding a key inherits from super-class - adding values applies to all sub-classes - removing values applies to all sub-classes

Currently this class is only used to keep the tree and return changed key- value-sets upon modification, since looking up the keys in an external cache, e.g. HashMap, is faster than tree traversal which must use linear scan at each level. Therefore, no value traversals are published.


Nested Class Summary
static class SubclassifiedIndex.Nonroot<K,V>
           
 
Constructor Summary
SubclassifiedIndex(Subclassification<K> sc)
           
 
Method Summary
 scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> addKey(K key)
          Add key to this index which inherits its value set from the most specific super-class which is known.
 scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> addValue(K key, V value)
          Add value to all keys which are subclasses of the given key.
static
<K,V> scala.collection.immutable.Map<K,scala.collection.immutable.Set<V>>
emptyMergeMap()
           
protected  scala.collection.immutable.Set<K> findSubKeysExcept(K key, scala.collection.immutable.Vector<SubclassifiedIndex.Nonroot<K,V>> except)
          Find all subkeys of a given key in the index excluding some subkeys.
protected  scala.collection.immutable.Set<V> findValues(K key)
          Find all values for a given key in the index.
protected  scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> innerAddKey(K key)
           
protected  scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> innerAddValue(K key, V value)
           
protected  scala.collection.immutable.Set<K> innerFindSubKeys(K key, scala.collection.immutable.Vector<SubclassifiedIndex.Nonroot<K,V>> except)
           
protected  scala.collection.immutable.Set<V> innerFindValues(K key)
           
protected  scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> innerRemoveValue(K key, V value)
           
 scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> removeValue(K key, V value)
          Remove value from all keys which are subclasses of the given key.
 scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> removeValue(V value)
          Remove value from all keys in the index.
protected  SubclassifiedIndex<K,V> root()
           
protected  scala.collection.immutable.Vector<SubclassifiedIndex.Nonroot<K,V>> subkeys()
           
 java.lang.String toString()
           
protected  scala.collection.immutable.Set<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SubclassifiedIndex

public SubclassifiedIndex(Subclassification<K> sc)
Method Detail

emptyMergeMap

public static <K,V> scala.collection.immutable.Map<K,scala.collection.immutable.Set<V>> emptyMergeMap()

values

protected scala.collection.immutable.Set<V> values()

subkeys

protected scala.collection.immutable.Vector<SubclassifiedIndex.Nonroot<K,V>> subkeys()

root

protected SubclassifiedIndex<K,V> root()

addKey

public scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> addKey(K key)
Add key to this index which inherits its value set from the most specific super-class which is known.

Parameters:
key - (undocumented)
Returns:
the diff that should be added to the cache

innerAddKey

protected scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> innerAddKey(K key)

addValue

public scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> addValue(K key,
                                                                                                  V value)
Add value to all keys which are subclasses of the given key. If the key is not known yet, it is inserted as if using addKey.

Parameters:
key - (undocumented)
value - (undocumented)
Returns:
the diff that should be added to the cache

innerAddValue

protected scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> innerAddValue(K key,
                                                                                                          V value)

removeValue

public scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> removeValue(K key,
                                                                                                     V value)
Remove value from all keys which are subclasses of the given key.

Parameters:
key - (undocumented)
value - (undocumented)
Returns:
the complete changes that should be updated in the cache

innerRemoveValue

protected scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> innerRemoveValue(K key,
                                                                                                             V value)

removeValue

public scala.collection.immutable.Seq<scala.Tuple2<K,scala.collection.immutable.Set<V>>> removeValue(V value)
Remove value from all keys in the index.

Parameters:
value - (undocumented)
Returns:
the diff that should be removed from the cache

findValues

protected final scala.collection.immutable.Set<V> findValues(K key)
Find all values for a given key in the index.

Parameters:
key - (undocumented)
Returns:
(undocumented)

innerFindValues

protected scala.collection.immutable.Set<V> innerFindValues(K key)

findSubKeysExcept

protected final scala.collection.immutable.Set<K> findSubKeysExcept(K key,
                                                                    scala.collection.immutable.Vector<SubclassifiedIndex.Nonroot<K,V>> except)
Find all subkeys of a given key in the index excluding some subkeys.

Parameters:
key - (undocumented)
except - (undocumented)
Returns:
(undocumented)

innerFindSubKeys

protected scala.collection.immutable.Set<K> innerFindSubKeys(K key,
                                                             scala.collection.immutable.Vector<SubclassifiedIndex.Nonroot<K,V>> except)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object