On Thu, Feb 2, 2012 at 8:30 PM, Takahiro Hozumi <[email protected]> wrote:
> 1. Resolve a server name which client should be connected to.
> If a client need to be connected to specific resource (chat room etc)
> consistent hashing is useful.
> http://nakkaya.com/2010/05/05/consistent-hashing-with-clojure/

> (defn sha1 [obj]
>   (let [bytes (.getBytes (with-out-str (pr obj)))]
>     (apply vector (.digest (MessageDigest/getInstance "SHA1") bytes))))

Ouch. Not simply the Java hash function? That will work for Clojure
objects that don't contain identities, only values. Whereas the above
has issues with sets and maps that are semantically equal but get put
together differently:

user=> (def x (array-map :a 1 :b 2))
#'user/x
user=> (def y (array-map :b 2 :a 1))
#'user/y
user=> (= (sha1 x) (sha1 y))
false

Oopsie.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to