Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/8314#discussion_r42936325
--- Diff:
core/src/main/scala/org/apache/spark/util/random/XORShiftRandom.scala ---
@@ -60,9 +60,11 @@ private[spark] class XORShiftRandom(init: Long) extends
JavaRandom(init) {
private[spark] object XORShiftRandom {
/** Hash seeds to have 0/1 bits throughout. */
- private def hashSeed(seed: Long): Long = {
+ private[random] def hashSeed(seed: Long): Long = {
val bytes =
ByteBuffer.allocate(java.lang.Long.SIZE).putLong(seed).array()
- MurmurHash3.bytesHash(bytes)
+ val lowBits = MurmurHash3.bytesHash(bytes)
+ val highBits = MurmurHash3.bytesHash(bytes, lowBits)
+ (highBits.toLong << 32) | (lowBits.toLong & 0xFFFFFFFFL)
--- End diff --
Although normally it might not be 100% valid to make a 64-bit hash out of
two 32-bit hashes this way (I'm not clear that reusing the seed doesn't connect
the bits in some subtle way), it's certainly a big improvement and probably
entirely fine for this purpose. I'd still like to remove XORShiftRandom, but
that can be for another day.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]