what type of hashing in scala

120 views
Skip to first unread message

shashank kapoor

unread,
Jan 4, 2016, 7:17:47 AM1/4/16
to scala-language
Hi
In scala what type of hashing is used? In java it is park-miller by default. So in scala what is the default hashing algorithm?


shashank kapoor

unread,
Jan 4, 2016, 9:39:21 AM1/4/16
to scala-l...@googlegroups.com
I see that there is documentation in any.scala that hashing is platform dependent, but how? and I can also see murmur hash 3 in code. Help me understand this.

On Mon, Jan 4, 2016 at 5:47 PM, shashank kapoor <shashank...@gmail.com> wrote:
Hi
In scala what type of hashing is used? In java it is park-miller by default. So in scala what is the default hashing algorithm?


--
You received this message because you are subscribed to a topic in the Google Groups "scala-language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-language/t_iDssWTplU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards
Shashank Kapoor

Sébastien Doeraene

unread,
Jan 4, 2016, 9:50:16 AM1/4/16
to scala-l...@googlegroups.com
Hi,

It is unclear what you are asking. Are you talking about the default hash code generation in AnyRef (aka Object)? Or are you talking about the hash code functions generated for case classes?

For case classes, the current implementation of Scala uses Murmur Hash 3. Although you should not rely on it, since it could change in future implementations.

For AnyRef.hashCode, that one is platform-dependent. On the JVM, it is whatever the JVM decides to use (e.g., Park-Miller, as you mentioned). On JavaScript, the current implementation always uses sequential numbers, although that could change in the future. In any case, you cannot rely on it.

Cheers,
Sébastien

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.

shashank kapoor

unread,
Jan 4, 2016, 9:57:54 AM1/4/16
to scala-l...@googlegroups.com
I was asking for AnyRef.
Thanx :)
Reply all
Reply to author
Forward
0 new messages