You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "johannaojeling (via GitHub)" <gi...@apache.org> on 2023/02/12 19:38:42 UTC

[GitHub] [beam] johannaojeling commented on a diff in pull request #25437: [Go SDK]: Allow SDF methods to have context param and error return value

johannaojeling commented on code in PR #25437:
URL: https://github.com/apache/beam/pull/25437#discussion_r1103864114


##########
sdks/go/pkg/beam/core/runtime/exec/sdf_invokers.go:
##########
@@ -39,61 +43,45 @@ import (
 
 // cirInvoker is an invoker for CreateInitialRestriction.
 type cirInvoker struct {
-	fn   *funcx.Fn
-	args []any // Cache to avoid allocating new slices per-element.
-	call func(elms *FullValue) (rest any)
+	fn     *funcx.Fn
+	args   []any // Cache to avoid allocating new slices per-element.
+	ctxIdx int
+	call   func() (rest any, err error)
 }
 
 func newCreateInitialRestrictionInvoker(fn *funcx.Fn) (*cirInvoker, error) {
 	n := &cirInvoker{
 		fn:   fn,
 		args: make([]any, len(fn.Param)),
 	}
+
+	var ok bool
+	if n.ctxIdx, ok = fn.Context(); !ok {
+		n.ctxIdx = -1
+	}
+
 	if err := n.initCallFn(); err != nil {
 		return nil, errors.WithContext(err, "sdf CreateInitialRestriction invoker")
 	}
 	return n, nil
 }
 
-func (n *cirInvoker) initCallFn() error {
-	// Expects a signature of the form:
-	// (key?, value) restriction
-	// TODO(BEAM-9643): Link to full documentation.
-	switch fnT := n.fn.Fn.(type) {
-	case reflectx.Func1x1:

Review Comment:
   I'm trying to understand in which cases the SDF methods are of type `reflectx.FuncMxN` (now moved to the generated file). I see the standard DoFn methods are wrapped into these types when using generic registration, however I cannot find that the same applies to the SDF methods



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org