<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>&nbsp; I would even make the case that the abs and the remainder operator are unnecessary.&nbsp; I&nbsp; 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.<br><br>&nbsp; These classes are under the examples section in a <a href="http://www.vizitsolutions.com/ConsistentHashingCaching.html">Consistent hashing and Caching doc</a> I am working on.<br><br>&nbsp;&nbsp; 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.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alex<br>&nbsp; <br><br>--- On <b>Mon, 9/14/09, Krzysztof Sobolewski <i>&lt;Krzysztof.Sobolewski@atm.com.pl&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Krzysztof Sobolewski &lt;Krzysztof.Sobolewski@atm.com.pl&gt;<br>Subject: [infinispan-dev] Hash calculation in DefaultConsistentHash<br>To: "infinispan-dev@lists.jboss.org"
 &lt;infinispan-dev@lists.jboss.org&gt;<br>Date: Monday, September 14, 2009, 4:25 AM<br><br><div class="plainMail">I took a look at the implementation of DefaultConsistentHash and I was <br>wondering: does the key hash value have to be positive? As in:<br><br>&nbsp; &nbsp; &nbsp; int hash = Math.abs(key.hashCode());<br><br>I can see that the resulting hash is used to pull a tail map of the hash <br>space, but there's no reason the SortedMap key has to be positive. I'm <br>actually most concerned about the fact that Math.abs(Integer.MIN_VALUE) == <br>Integer.MIN_VALUE so you have at least one negative key anyway :)<br>-KS<br>_______________________________________________<br>infinispan-dev mailing list<br><a ymailto="mailto:infinispan-dev@lists.jboss.org" href="/mc/compose?to=infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev"
 target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br></div></blockquote></td></tr></table><br>