New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hashCode of Product inconsistent on different machines/configurations #1387
Comments
Imported From: https://issues.scala-lang.org/browse/SI-1387?orig=1
|
@mcdirmid said: |
@dlwh said: I'd personally like to see this fixed by 2.7.2, as this is a very minor change, to that end, I'm attaching a patch. |
@dlwh said: |
@ijuma said: |
@DRMacIver said: |
In my attempts to get a more scala friendly library for Hadoop, I've
come across this in ScalaRuntime
84 def _hashCode(x: Product): Int = {
85 var code = x.getClass().hashCode()
86 val arr = x.productArity
87 var i = 0
88 while (i < arr) {
89 code = code * 41 + x.productElement(i).hashCode()
90 i += 1
91 }
92 code
93 }
94
Sadly, x.getClass.getHashCode doesn't seem to be consistent across
different machines or different executions (not sure which), which
makes it useless in Hadoop, since Hadoop assumes that hashCode is the same no matter the machine. Any chance we could get this changed?
How about:
var code = x.productPrefix.hashCode();
or var code = x.getClass.getName.hashCode() ?
The text was updated successfully, but these errors were encountered: