You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/02/08 18:08:34 UTC
[GitHub] [beam] damccorm commented on a change in pull request #16775: [BEAM-13803] Add support for native iterable side inputs to the Go SDK
damccorm commented on a change in pull request #16775:
URL: https://github.com/apache/beam/pull/16775#discussion_r801914322
##########
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:
Could you help me understand why we need an encoder and decoder in the KV case, and just a decoder in this case (aka, please help Danny understand how we use Coders 😅)
##########
File path: sdks/go/pkg/beam/core/runtime/graphx/translate.go
##########
@@ -418,7 +379,7 @@ func (m *marshaller) addMultiEdge(edge NamedEdge) ([]string, error) {
si[fmt.Sprintf("i%v", i)] = &pipepb.SideInput{
AccessPattern: &pipepb.FunctionSpec{
- Urn: URNMultimapSideInput,
+ Urn: URNIterableSideInput,
},
ViewFn: &pipepb.FunctionSpec{
Urn: "foo",
Review comment:
I know this is coming from the MultiMap version of this, but what does `Urn: "foo"` actually do here? Is this doing something different than just leaving the ViewFn empty would?
--
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