org.planx.xmlstore.routing
Class HashCalculator

java.lang.Object
  extended by org.planx.xmlstore.routing.HashCalculator

public class HashCalculator
extends Object

Calculates group hashes for mappings.


Field Summary
static int HASH_LENGTH
           
static long UNIT_INTERVAL
           
 
Constructor Summary
HashCalculator(Node local, Space space, Map localMap)
           
 
Method Summary
 byte[] calculateHash(List bundle)
          Calculates a unique hash of the keys in the specified bundle.
 List logarithmicHashes(Node node, long time)
          Calculates bundled hashes of the set of keys which is the intersection of keys that both the local node and the specified node are responsible for.
 List mappingsBetween(Node node, long begin, long end)
          Returns the subset of mappings in the local map with timestamps between begin (including) and end (not including) that the specified node is also responsible for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HASH_LENGTH

public static final int HASH_LENGTH
See Also:
Constant Field Values

UNIT_INTERVAL

public static final long UNIT_INTERVAL
See Also:
Constant Field Values
Constructor Detail

HashCalculator

public HashCalculator(Node local,
                      Space space,
                      Map localMap)
Method Detail

logarithmicHashes

public List logarithmicHashes(Node node,
                              long time)
Calculates bundled hashes of the set of keys which is the intersection of keys that both the local node and the specified node are responsible for. The keys are bundled in bundles of exponentially increasing size in the time difference from time, so that the older the timestamp the larger the bundle. Keys with timestamp greater then time are grouped in one large bundle. The returned list will contain O(log N) hashes, where N is the number of mappings.

Returns:
List of hashes as byte arrays

mappingsBetween

public List mappingsBetween(Node node,
                            long begin,
                            long end)
Returns the subset of mappings in the local map with timestamps between begin (including) and end (not including) that the specified node is also responsible for. That is, the specified node and the local node is one of the K closest nodes to each key. The mappings are returned as TimestampedEntry objects in a List sorted by their timestamp in ascending order.


calculateHash

public byte[] calculateHash(List bundle)
Calculates a unique hash of the keys in the specified bundle. The bundle is a list of TimestampedEntry objects. To get consistent hashing the bundle should be ordered in a deterministic way. This is that case for lists returned by mappingsBetween(org.planx.xmlstore.routing.Node, long, long).



Copyright © 2010. All Rights Reserved.