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


##########
sdks/go/pkg/beam/runners/prism/internal/handlepardo.go:
##########
@@ -0,0 +1,242 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package internal
+
+import (
+       "fmt"
+       "reflect"
+
+       pipepb "github.com/apache/beam/sdks/v2/go/pkg/beam/model/pipeline_v1"
+       "github.com/apache/beam/sdks/v2/go/pkg/beam/runners/prism/internal/urns"
+       "golang.org/x/exp/maps"
+       "google.golang.org/protobuf/proto"
+)
+
+// This file retains the logic for the pardo handler
+
+// ParDoCharacteristic holds the configuration for ParDos.
+type ParDoCharacteristic struct {
+       DisableSDF bool // Sets whether a pardo supports SDFs or not.
+}
+
+func ParDo(config any) *pardo {
+       return &pardo{config: config.(ParDoCharacteristic)}
+}
+
+// pardo represents an instance of the pardo handler.
+type pardo struct {
+       config ParDoCharacteristic
+}
+
+// ConfigURN returns the name for combine in the configuration file.
+func (*pardo) ConfigURN() string {
+       return "pardo"
+}
+
+func (*pardo) ConfigCharacteristic() reflect.Type {
+       return reflect.TypeOf((*ParDoCharacteristic)(nil)).Elem()
+}
+
+var _ transformPreparer = (*pardo)(nil)
+
+func (*pardo) PrepareUrns() []string {
+       return []string{urns.TransformParDo}
+}
+
+// PrepareTransform handles special processing with respect to ParDos, since 
their handling is dependant on supported features
+// and requirements.
+func (h *pardo) PrepareTransform(tid string, t *pipepb.PTransform, comps 
*pipepb.Components) (*pipepb.Components, []string) {
+
+       // ParDos are a pain in the butt.
+       // Combines, by comparison, are dramatically simpler.
+       // This is because for ParDos, how they are handled, and what kinds of 
transforms are in
+       // and around the ParDo, the actual shape of the graph will change.
+       // At their simplest, it's something a DoFn will handle on their own.
+       // At their most complex, they require intimate interaction with the 
subgraph
+       // bundling process, the data layer, state layers, and control layers.
+       // But unlike combines, which have a clear urn for composite + special 
payload,
+       // ParDos have the standard URN for composites with the standard 
payload.
+       // So always, we need to first unmarshal the payload.
+
+       pardoPayload := t.GetSpec().GetPayload()
+       pdo := &pipepb.ParDoPayload{}
+       if err := (proto.UnmarshalOptions{}).Unmarshal(pardoPayload, pdo); err 
!= nil {
+               panic(fmt.Sprintf("unable to decode ParDoPayload for 
transform[%v]", t.GetUniqueName()))
+       }
+
+       // Lets check for and remove anything that makes things less simple.
+       if pdo.OnWindowExpirationTimerFamilySpec == "" &&
+               !pdo.RequestsFinalization &&
+               !pdo.RequiresStableInput &&
+               !pdo.RequiresTimeSortedInput &&
+               //      len(pdo.SideInputs) == 0 &&

Review Comment:
   No. I have a comment elsewhere about side inputs.



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

Reply via email to