[ 
https://issues.apache.org/jira/browse/BEAM-9642?focusedWorklogId=421813&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-421813
 ]

ASF GitHub Bot logged work on BEAM-9642:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Apr/20 03:21
            Start Date: 14/Apr/20 03:21
    Worklog Time Spent: 10m 
      Work Description: youngoli commented on pull request #11327: [BEAM-9642] 
Add SDF execution units.
URL: https://github.com/apache/beam/pull/11327#discussion_r407827873
 
 

 ##########
 File path: sdks/go/pkg/beam/core/runtime/exec/sdf.go
 ##########
 @@ -0,0 +1,297 @@
+// 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 exec
+
+import (
+       "context"
+       "fmt"
+       "github.com/apache/beam/sdks/go/pkg/beam/core/graph"
+       "path"
+
+       "github.com/apache/beam/sdks/go/pkg/beam/internal/errors"
+)
+
+// PairWithRestriction is an executor for the expanded SDF step of the same
+// name. This is the first step of an expanded SDF. It pairs each main input
+// element with a restriction via the SDF's associated sdf.RestrictionProvider.
+// This step is followed by SplitAndSizeRestrictions.
+type PairWithRestriction struct {
+       UID UnitID
+       Fn  *graph.DoFn
+       Out []Node
+
+       inv *cirInvoker
+}
+
+// ID returns the UnitID for this unit.
+func (n *PairWithRestriction) ID() UnitID {
+       return n.UID
+}
+
+// Up performs one-time setup for this executor.
+func (n *PairWithRestriction) Up(ctx context.Context) error {
+       fn := (*graph.SplittableDoFn)(n.Fn).CreateInitialRestrictionFn()
+       var err error
+       if n.inv, err = newCreateInitialRestrictionInvoker(fn); err != nil {
+               return errors.WithContextf(err, "PairWithRestriction transform 
with UID %v", n.ID())
+       }
+       return nil
+}
+
+// StartBundle currently does nothing.
+func (n *PairWithRestriction) StartBundle(ctx context.Context, id string, data 
DataContext) error {
+       return n.Out[0].StartBundle(ctx, id, data)
+}
+
+// ProcessElement expects elm to be the main input to the ParDo. See
+// exec.FullValue for more details on the expected input.
+//
+// ProcessElement creates an initial restriction representing the entire input.
+// The output is in the structure <elem, restriction>, where elem is the main
+// input originally passed in (i.e. the parameter elm). Windows and Timestamp
+// are copied to the outer *FullValue. They still remain within the original
+// element as well, but will no longer be used.
+//
+// Output Diagram:
+//
+//   *FullValue {
+//     Elm: *FullValue (original input)
+//     Elm2: Restriction
+//     Windows
+//     Timestamps
+//   }
+func (n *PairWithRestriction) ProcessElement(ctx context.Context, elm 
*FullValue, values ...ReStream) error {
+       rest := n.inv.Invoke(elm)
+       output := FullValue{Elm: elm, Elm2: rest, Timestamp: elm.Timestamp, 
Windows: elm.Windows}
+
+       return n.Out[0].ProcessElement(ctx, &output, values...)
+}
+
+// FinishBundle does some teardown for the end of the bundle.
+func (n *PairWithRestriction) FinishBundle(ctx context.Context) error {
+       n.inv.Reset()
+       return n.Out[0].FinishBundle(ctx)
+}
+
+// Down currently does nothing.
+func (n *PairWithRestriction) Down(ctx context.Context) error {
+       return nil
+}
+
+// String outputs a human-readable description of this transform.
+func (n *PairWithRestriction) String() string {
+       return fmt.Sprintf("SDF.PairWithRestriction[%v] Out:%v", 
path.Base(n.Fn.Name()), IDs(n.Out...))
+}
+
+// SplitAndSizeRestrictions is an executor for the expanded SDF step of the
+// same name. It is the second step of the expanded SDF, occuring after
+// CreateInitialRestriction. It performs initial splits on the initial 
restrictions
+// and adds sizing information, producing one or more output elements per input
+// element. This step is followed by ProcessSizedElementsAndRestrictions.
+type SplitAndSizeRestrictions struct {
+       UID UnitID
+       Fn  *graph.DoFn
+       Out []Node
 
 Review comment:
   This was me copying from the old implementation, which had all these nodes 
wrapping ParDos. No, these shouldn't be outputting to more than one transform, 
so I'll change this.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 421813)
    Time Spent: 3h 50m  (was: 3h 40m)

> Add SDF execution-time runners
> ------------------------------
>
>                 Key: BEAM-9642
>                 URL: https://issues.apache.org/jira/browse/BEAM-9642
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-go
>            Reporter: Daniel Oliveira
>            Assignee: Daniel Oliveira
>            Priority: Major
>          Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> Adds execution-time SDF runner units to the exec package, and any unit tests 
> + helpers required.
> This is needed to get the expanded SDF URNs to execute in the runner harness.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to