lostluck commented on code in PR #17799:
URL: https://github.com/apache/beam/pull/17799#discussion_r898265444


##########
sdks/go/examples/snippets/04transforms.go:
##########
@@ -203,6 +209,8 @@ func formatCoGBKResults(key string, emailIter, phoneIter 
func(*string) bool) str
 
 func init() {
        beam.RegisterFunction(formatCoGBKResults)

Review Comment:
   register.Function3x1(formatCoGBKResults) ?
   
   Similar elsewhere in the change.



##########
website/www/site/content/en/documentation/programming-guide.md:
##########
@@ -862,7 +885,11 @@ Simple DoFns can also be written as functions.
 func ComputeWordLengthFn(word string, emit func(int)) { ... }
 
 func init() {
-       beam.RegisterFunction(ComputeWordLengthFn)
+  // 2 inputs and 0 outputs => DoFn2x0
+  // 1 input => Emitter1
+  // Input/output types are included in order in the brackets
+  register.DoFn2x0[string, func(int)](&ComputeWordLengthFn{})

Review Comment:
   This would need to use register.Function2x0 IIRC, and can then avoid 
specifying the type parameters since they're inferable.



##########
website/www/site/content/en/documentation/programming-guide.md:
##########
@@ -1710,9 +1757,10 @@ a remote worker in your processing cluster.
 as `DoFn`, `CombineFn`, and `WindowFn`, already implement `Serializable`;
 however, your subclass must not add any non-serializable members.</span>
 <span class="language-go">Funcs are serializable as long as
-they are registered with `beam.RegisterFunction`, and are not
-closures. Structural `DoFn`s will have all exported fields serialized.
-Unexported fields are unable to be serialized, and will be silently 
ignored.</span>
+they are registered with `beam.RegisterFunction` (for simple functions) or

Review Comment:
   We should recommend the `register.FunctionXxY` registrations here instead.
   
   We should mark the old registration methods as deprecated in 2.41.0, and 
link to the advice here.



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