wbo4958 commented on PR #37855:
URL: https://github.com/apache/spark/pull/37855#issuecomment-1260417639

   > Good catch! seems we can also simply switch to `XORShiftRandom` which 
always [hash the 
seeds](https://github.com/apache/spark/blob/e1ea806b3075d279b5f08a29fe4c1ad6d3c4191a/core/src/main/scala/org/apache/spark/util/random/XORShiftRandom.scala#L58-L67)
   > 
   > ```
   > scala> (1 to 200).map(partitionId => new Random(partitionId).nextInt(4))
   > val res3: IndexedSeq[Int] = Vector(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2)
   > 
   > scala> (1 to 200).map(partitionId => new 
XORShiftRandom(partitionId).nextInt(4))
   > val res4: IndexedSeq[Int] = Vector(0, 3, 2, 2, 3, 3, 1, 2, 2, 0, 2, 2, 2, 
1, 2, 2, 0, 3, 2, 0, 3, 3, 1, 1, 1, 1, 0, 0, 2, 3, 1, 3, 0, 1, 1, 2, 0, 2, 1, 
3, 3, 0, 0, 1, 1, 3, 0, 2, 1, 1, 2, 0, 1, 3, 0, 0, 0, 1, 0, 3, 2, 1, 3, 3, 3, 
0, 1, 0, 3, 0, 0, 0, 3, 0, 2, 1, 0, 2, 0, 2, 2, 0, 3, 0, 2, 3, 0, 1, 1, 1, 1, 
3, 3, 3, 3, 3, 0, 1, 3, 1, 3, 0, 2, 1, 2, 1, 3, 0, 1, 1, 0, 2, 0, 0, 3, 0, 2, 
1, 1, 2, 0, 3, 1, 3, 1, 0, 0, 2, 3, 1, 2, 1, 3, 0, 1, 2, 2, 2, 1, 3, 3, 3, 0, 
2, 2, 3, 0, 1, 0, 3, 0, 2, 1, 2, 1, 2, 1, 1, 3, 3, 0, 2, 0, 0, 1, 1, 1, 1, 2, 
0, 0, 1, 0, 1, 3, 0, 3, 1, 1, 3, 2, 3, 1, 2, 3, 0, 3, 3, 2, 3, 0, 0, 1, 1, 0, 
2, 1, 0, 0, 2)
   > ```
   
   Yeah, I tried XORShiftRandom is working well, see 
https://github.com/apache/spark/pull/37855#issuecomment-1245363471


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to