|
From: Yonik S. <yo...@ap...> - 2008-03-18 19:57:03
|
On Tue, Mar 18, 2008 at 11:01 AM, Ning Li <nin...@gm...> wrote: > On Mon, Mar 17, 2008 at 7:28 PM, Yonik Seeley <yo...@ap...> wrote: > > Or did you mean represent the hash as a String? > > Yes. :) Ah, OK... so like a variable length int. The ring management and passing of ranges with Strings would be easy enough, but depending on what needs to be done on a node, it may be less efficient. For example, to find a range of hashes (say to split of a piece for rebalancing) we would probably use either the FieldCache, or a colum stored field (upcoming) in Lucene, both of which would be more efficient as an int. > Converting a string to a number while maintaining the string order, > on the other hand, is difficult. If one wants each user in an email system to span a maximum of 1/8th of the ring then the hash could be hash = (username.hashCode() << 29) | (id.hashCode() >> 3) Or if the number of emails per user is small, hash = username.hashCode() -Yonik |