[infinispan-dev] Hash calculation in DefaultConsistentHash

Alex Kluge java_kluge at yahoo.com
Mon Sep 14 16:05:44 EDT 2009


Hi,

  I would even make the case that the abs and the remainder operator are unnecessary.  I  have an version of a consistent hash which is similar to this, and made a few modifications so that my code delivers the same functionality as the current infinispan DefaultConsistentHash. The consistent hash is much more natural if you directly use the hash values. I had meant to contribute this code a while back, but I was simply too busy getting the full project of which this is a part to a testable state to make the infinispan modifications to the code.

  These classes are under the examples section in a Consistent hashing and Caching doc I am working on.

   This code also supports virtual nodes, but with the settings in the example do not produce any. The builder is there to facilitate the creation of the hash through an XML parser, while keeping the hash itself immutable. These things can all be tuned or changed for infinispan's specific needs.

                                                    Alex
  

--- On Mon, 9/14/09, Krzysztof Sobolewski <Krzysztof.Sobolewski at atm.com.pl> wrote:

From: Krzysztof Sobolewski <Krzysztof.Sobolewski at atm.com.pl>
Subject: [infinispan-dev] Hash calculation in DefaultConsistentHash
To: "infinispan-dev at lists.jboss.org" <infinispan-dev at lists.jboss.org>
Date: Monday, September 14, 2009, 4:25 AM

I took a look at the implementation of DefaultConsistentHash and I was 
wondering: does the key hash value have to be positive? As in:

      int hash = Math.abs(key.hashCode());

I can see that the resulting hash is used to pull a tail map of the hash 
space, but there's no reason the SortedMap key has to be positive. I'm 
actually most concerned about the fact that Math.abs(Integer.MIN_VALUE) == 
Integer.MIN_VALUE so you have at least one negative key anyway :)
-KS
_______________________________________________
infinispan-dev mailing list
infinispan-dev at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/infinispan-dev/attachments/20090914/e7c4950a/attachment-0002.html 


More information about the infinispan-dev mailing list