[ 
https://issues.apache.org/jira/browse/BEAM-3612?focusedWorklogId=170767&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-170767
 ]

ASF GitHub Bot logged work on BEAM-3612:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 29/Nov/18 18:49
            Start Date: 29/Nov/18 18:49
    Worklog Time Spent: 10m 
      Work Description: wcn3 commented on a change in pull request #7161: 
[BEAM-3612] Closurize method invocations
URL: https://github.com/apache/beam/pull/7161#discussion_r237611764
 
 

 ##########
 File path: sdks/go/pkg/beam/core/util/reflectx/structs.go
 ##########
 @@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package reflectx
+
+import (
+       "context"
+       "reflect"
+       "sync"
+
+       "github.com/apache/beam/sdks/go/pkg/beam/log"
+)
+
+var (
+       structFuncs   = make(map[string]func(interface{}) map[string]Func)
+       structFuncsMu sync.Mutex
+)
+
+// RegisterStructWrapper takes in the reflect.Type of a structural DoFn, and
+// a wrapping function that will take an instance of that struct type and
+// produce a map of method names to of closured Funcs that call the method
+// on the instance of the struct.
+//
+// The goal is to avoid the implicit reflective method invocation penalty
+// that occurs when passing a method through the reflect package.
+func RegisterStructWrapper(t reflect.Type, wrapper func(interface{}) 
map[string]Func) {
+       structFuncsMu.Lock()
+       defer structFuncsMu.Unlock()
+
+       if t.Kind() != reflect.Struct {
+               log.Fatalf(context.Background(), "RegisterStructWrapper for %v 
should be a struct type, but was %v", t, t.Kind())
 
 Review comment:
   Is this the extent of validity checking that can be performed on the struct? 
No required members?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 170767)

> Make it easy to generate type-specialized Go SDK reflectx.Funcs
> ---------------------------------------------------------------
>
>                 Key: BEAM-3612
>                 URL: https://issues.apache.org/jira/browse/BEAM-3612
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Henning Rohde
>            Assignee: Robert Burke
>            Priority: Major
>          Time Spent: 7.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to