uniqueness of hash if computed on different jvms across different machines.
Hi, Is the clojure hash function guaranteed to produce the same hash on different jvms running on different jvms for the same "data-structure" which would satisfy "equality" if checked on a single jvm. The data structure is simply a hash-map. Thanks, Sunil. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: uniqueness of hash if computed on different jvms across different machines.
For immutable values (including hash-maps containing only immutable values), I believe the answer is yes, if you are using the same version of Clojure on the different jvms (at least, I cannot think of any counterexamples in a few minutes of thinking about it, and I have looked at the hash function implementations in Clojure in some detail before because of [1]). For mutable values (or hash-maps containing mutable values), there are whatever guarantees Java makes for its .hashCode method. Most of the hash values computed changed between Clojure 1.5.1 and Clojure 1.6.0 [1] to avoid hash collisions that were common for collections. There is no guarantee I know of that future versions of Clojure will not change hash functions again. These facts prompt me to wonder: Why do you want to know if there is such a guarantee? Saving such hash values on disk, for example, will expose you to possible changes to those values in future versions of Clojure. Using them to communicate between different JVMs will limit the application to running versions of Clojure on those multiple JVMs with the same hash functions (either the same version of Clojure, or 'hash compatible' versions of Clojure). Andy [1] https://github.com/clojure/clojure/blob/master/changes.md#24-hashing On Sun, Oct 12, 2014 at 11:04 PM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hi, > Is the clojure hash function guaranteed to produce the same hash on > different jvms running on different jvms for the same "data-structure" > which would satisfy "equality" if checked on a single jvm. The data > structure is simply a hash-map. > Thanks, > Sunil. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: uniqueness of hash if computed on different jvms across different machines.
In addition to Andy's caveats, remember that hash code equality doesn't imply object equality. In concrete terms, a = b implies h(a) = h(b), with the useful bit being h(a) ≠ h(b) implies a ≠ b. On Monday, October 13, 2014 2:04:57 AM UTC-4, Sunil Nandihalli wrote: > > Hi, > Is the clojure hash function guaranteed to produce the same hash on > different jvms running on different jvms for the same "data-structure" > which would satisfy "equality" if checked on a single jvm. The data > structure is simply a hash-map. > Thanks, > Sunil. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: uniqueness of hash if computed on different jvms across different machines.
I would expect that right now the same version of Clojure would typically give you the same hash for the same data structure across different JVM instances. HOWEVER, I would consider this accidental, not a guarantee. Certainly the hash values may change across Clojure or JDK versions. Additionally the JVM (specifically in some JDK 1.7 versions and settings) and other languages seed hash calculation with an instance-specific value to foil hash-based DDOS attacks. Clojure may employ such a strategy in the future. I would not state any guarantee beyond this: "In a particular JVM instance, two Clojure data structures that are =, will have the same hasheq value." If you want a hash computation you can rely on across JVM and Clojure versions and instances, you should compute it with your own code. On Monday, October 13, 2014 9:55:09 AM UTC-5, Andy Fingerhut wrote: > > For immutable values (including hash-maps containing only immutable > values), I believe the answer is yes, if you are using the same version of > Clojure on the different jvms (at least, I cannot think of any > counterexamples in a few minutes of thinking about it, and I have looked at > the hash function implementations in Clojure in some detail before because > of [1]). For mutable values (or hash-maps containing mutable values), > there are whatever guarantees Java makes for its .hashCode method. > > Most of the hash values computed changed between Clojure 1.5.1 and Clojure > 1.6.0 [1] to avoid hash collisions that were common for collections. > > There is no guarantee I know of that future versions of Clojure will not > change hash functions again. > > These facts prompt me to wonder: Why do you want to know if there is such > a guarantee? Saving such hash values on disk, for example, will expose you > to possible changes to those values in future versions of Clojure. Using > them to communicate between different JVMs will limit the application to > running versions of Clojure on those multiple JVMs with the same hash > functions (either the same version of Clojure, or 'hash compatible' > versions of Clojure). > > Andy > > > [1] https://github.com/clojure/clojure/blob/master/changes.md#24-hashing > > On Sun, Oct 12, 2014 at 11:04 PM, Sunil S Nandihalli < > sunil.na...@gmail.com > wrote: > >> Hi, >> Is the clojure hash function guaranteed to produce the same hash on >> different jvms running on different jvms for the same "data-structure" >> which would satisfy "equality" if checked on a single jvm. The data >> structure is simply a hash-map. >> Thanks, >> Sunil. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+u...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.