[infinispan-dev] Hash calculation in DefaultConsistentHash

Krzysztof Sobolewski Krzysztof.Sobolewski at atm.com.pl
Mon Sep 14 05:25:15 EDT 2009


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



More information about the infinispan-dev mailing list