youngoli commented on a change in pull request #13245:
URL: https://github.com/apache/beam/pull/13245#discussion_r518452815



##########
File path: sdks/go/pkg/beam/io/synthetic/source.go
##########
@@ -131,8 +130,19 @@ func (fn *sourceFn) ProcessElement(rt *sdf.LockRTracker, 
config SourceConfig, em
        for i := rt.GetRestriction().(offsetrange.Restriction).Start; 
rt.TryClaim(i) == true; i++ {
                key := make([]byte, config.KeySize)
                val := make([]byte, config.ValueSize)
-               if _, err := fn.rng.Read(key); err != nil {
-                       return err
+               generator := sourceFn{}
+               generator.rng = rand.New(rand.NewSource(i))

Review comment:
       Hm... I have objections with the way that one is coded too, but that's 
something for me to discuss with the original author. It's definitely 
reasonable to match the Python implementation.
   
   In that case, my only remaining advice is, instead of creating a new Rand 
object with a new source each time you want to reseed (in other words, in each 
position), create the Rand objects in the beginning of `ProcessElement` and 
then call [Rand.Seed](https://golang.org/pkg/math/rand/#Rand.Seed) when you 
want to reseed.




----------------------------------------------------------------
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.

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


Reply via email to