lostluck commented on a change in pull request #15657:
URL: https://github.com/apache/beam/pull/15657#discussion_r738573767



##########
File path: sdks/go/pkg/beam/core/metrics/metrics.go
##########
@@ -136,6 +136,10 @@ func SetPTransformID(ctx context.Context, id string) 
context.Context {
        // Checking for *beamCtx is an optimization, so we don't dig deeply
        // for ids if not necessary.
        if bctx, ok := ctx.(*beamCtx); ok {
+               if _, ok := bctx.store.stateRegistry[id]; !ok {
+                       bctx.store.stateRegistry[id] = 
[4]*ExecutionState{&ExecutionState{}, &ExecutionState{}, &ExecutionState{}, 
&ExecutionState{}}

Review comment:
       Ah, I see what you mean. Then make the stateRegistry field type 
`map[string]*[4]ExecutionState` Making it a pointer to the array, rather than 
an array of pointers.
   
   Then this line can become `bctx.store.stateRegistry[id] = 
&[4]ExecutionState{}`
   
   It's a map, keyed by strings, to pointers of arrays of length 4.
   
   
   




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


Reply via email to