jrmccluskey commented on a change in pull request #16775: URL: https://github.com/apache/beam/pull/16775#discussion_r802032193
########## File path: sdks/go/pkg/beam/core/runtime/exec/sideinput.go ########## @@ -43,26 +43,71 @@ type sideInputAdapter struct { kc ElementEncoder ec ElementDecoder wm WindowMapper + c *coder.Coder } // NewSideInputAdapter returns a side input adapter for the given StreamID and coder. -// It expects a W<KV<K,V>> coder, because the protocol supports MultiSet access only. +// It expects a W<V> or W<KV<K,V>> coder, because the protocol requires windowing information. func NewSideInputAdapter(sid StreamID, sideInputID string, c *coder.Coder, wm WindowMapper) SideInputAdapter { - if !coder.IsW(c) || !coder.IsKV(coder.SkipW(c)) { - panic(fmt.Sprintf("expected WKV coder for side input %v: %v", sid, c)) + if !coder.IsW(c) { + panic(fmt.Sprintf("expected WV coder for side input %v: %v", sid, c)) } wc := MakeWindowEncoder(c.Window) - kc := MakeElementEncoder(coder.SkipW(c).Components[0]) - ec := MakeElementDecoder(coder.SkipW(c).Components[1]) - return &sideInputAdapter{sid: sid, sideInputID: sideInputID, wc: wc, kc: kc, ec: ec, wm: wm} + var kc ElementEncoder + var ec ElementDecoder + if coder.IsKV(coder.SkipW(c)) { + kc = MakeElementEncoder(coder.SkipW(c).Components[0]) + ec = MakeElementDecoder(coder.SkipW(c).Components[1]) + } else { + ec = MakeElementDecoder(coder.SkipW(c)) Review comment: In this particular context, we need coders when we're communicating with the runner over the Fn API. The key we are querying for the side input in a keyed context needs to be encoded when put into the proto, and then we need to decode the elements we get out from the runner so we can pass them back in the correct form. -- 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-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org