org.jboss.cache.util
Class Caches.HashKeySelector<T>

java.lang.Object
  extended by org.jboss.cache.util.Caches.HashKeySelector<T>
All Implemented Interfaces:
Caches.ChildSelector<T>
Enclosing class:
Caches

public static class Caches.HashKeySelector<T>
extends Object
implements Caches.ChildSelector<T>

Class that returns a child name to use based on the hash code of a key.


Field Summary
protected  int segments
           
 
Constructor Summary
Caches.HashKeySelector(int segments)
          Constructs with N segments, where N must be a power of 2.
 
Method Summary
protected  Fqn childName(int segment)
          Returns the node name for this segment.
 Fqn childName(T key)
          Returns the node name for this key.
protected  int segmentFor(T key)
          Returns the segment for this key, in the inclusive range 0 to segments - 1.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

segments

protected int segments
Constructor Detail

Caches.HashKeySelector

public Caches.HashKeySelector(int segments)
Constructs with N segments, where N must be a power of 2.

Parameters:
segments - Number of hash segments
Method Detail

segmentFor

protected final int segmentFor(T key)
Returns the segment for this key, in the inclusive range 0 to segments - 1.


childName

protected final Fqn childName(int segment)
Returns the node name for this segment.


childName

public final Fqn childName(T key)
Returns the node name for this key. By default, returns a String containing the segment.

Specified by:
childName in interface Caches.ChildSelector<T>
Parameters:
key - for calls to Map.put(K, V), Map.get(java.lang.Object) etc.
Returns:
node name

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.