Hey Alex,
On 09/14/2009 10:05 PM, Alex Kluge wrote:
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.
Any chance of sharing this work with the rest of Infinispan community at
some point?
Regards,
Alex
--- On Mon, 9/14/09, Krzysztof Sobolewski<Krzysztof.Sobolewski(a)atm.com.pl> wrote:
From: Krzysztof Sobolewski<Krzysztof.Sobolewski(a)atm.com.pl>
Subject: [infinispan-dev] Hash calculation in DefaultConsistentHash
To: "infinispan-dev@lists.jboss.org"<infinispan-dev(a)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(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev
------------------------------------------------------------------------
_______________________________________________
infinispan-dev mailing list
infinispan-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev
--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache