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

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

                Author: ASF GitHub Bot
            Created on: 19/Mar/20 00:58
            Start Date: 19/Mar/20 00:58
    Worklog Time Spent: 10m 
      Work Description: lostluck commented on pull request #11144: [BEAM-3301] 
Perform SDF validation (missing RestrictionTrackers).
URL: https://github.com/apache/beam/pull/11144#discussion_r394725254
 
 

 ##########
 File path: sdks/go/pkg/beam/core/graph/fn.go
 ##########
 @@ -569,6 +622,188 @@ func validateSideInputsNumUnknown(processFnInputs 
[]funcx.FnParam, method *funcx
        return nil
 }
 
+// validateSdfMethods validates that all SDF methods are either present or
+// missing in a Fn, and then returns true if they're present and false
+// otherwise. If some are present and some are missing, it returns an error.
+func validateSdfMethodsPresent(fn *Fn) (bool, error) {
+       // Check if first sdf method is present or not, and compare all 
subsequent
+       // methods to that result. If there's a mismatch, then we only fail 
after
+       // finishing the loop so we can output all the missing methods.
+       missing := make([]string, 0)
+       var first, fail bool
+
+       for i, name := range sdfNames {
+               _, ok := fn.methods[name]
+               if !ok {
+                       missing = append(missing, name)
+               }
+
+               if i == 0 {
+                       first = ok
+               } else if ok != first {
+                       fail = true
+               }
+       }
+
+       if fail {
+               err := errors.Errorf("not all SplittableDoFn methods are 
present. Missing methods: %v", missing)
+               return false, err
+       }
+
+       return first, nil
 
 Review comment:
   I see that this function is trying to distinguish between partial coverage 
or complete coverage, but I think it could be simpler.
   
   Consider that the booleans could be removed by comparing whether 
len(missing) == len(sdfNames) to check if it's simply not an SDF at all (and 
thus, no error should be returned). 
   
   ```
   switch len(missing) {
   case 0: 
     return true, nil
   case len(sdfNames): 
     return false, nil
   default:
     err := errors.Errorf("not all SplittableDoFn methods are present. Missing 
methods: %v", missing)
     return false, err
   }
   ```
   
 
----------------------------------------------------------------
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]


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

    Worklog Id:     (was: 405881)
    Time Spent: 5h 40m  (was: 5.5h)

> Go SplittableDoFn support
> -------------------------
>
>                 Key: BEAM-3301
>                 URL: https://issues.apache.org/jira/browse/BEAM-3301
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Henning Rohde
>            Assignee: Daniel Oliveira
>            Priority: Major
>          Time Spent: 5h 40m
>  Remaining Estimate: 0h
>
> SDFs will be the only way to add streaming and liquid sharded IO for Go.
> Design doc: https://s.apache.org/splittable-do-fn



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to