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/04/13 17:30:12 UTC

[GitHub] [beam] lostluck commented on a diff in pull request #17267: [BEAM-11105] Basic Watermark Estimation (Wall Clock Observing)

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


##########
sdks/go/pkg/beam/core/graph/fn.go:
##########
@@ -913,6 +948,64 @@ func validateSdfElementT(fn *Fn, name string, method *funcx.Fn, num int) error {
 	return nil
 }
 
+// validateIsWatermarkEstimating returns true if watermark estimator methods are present on the DoFn, returns
+// false if they aren't, and returns an error if they are present but the function isn't an sdf and thus doesn't
+// support watermark estimation
+func validateIsWatermarkEstimating(fn *Fn, isSdf bool) (bool, error) {
+	var isWatermarkEstimating bool
+	if _, ok := fn.methods[createWatermarkEstimatorName]; ok {
+		isWatermarkEstimating = true
+	}
+	if !isSdf && isWatermarkEstimating {
+		return false, errors.Errorf("Watermark estimation method %v is defined on non-splittable DoFn. Watermark"+
+			"estimation is only valid on splittable DoFns", createWatermarkEstimatorName)
+	}
+	return isWatermarkEstimating, nil
+}
+
+// validateWatermarkSig validates that all watermark related functions are valid
+func validateWatermarkSig(fn *Fn) error {
+	paramRange := map[string][]int{
+		createWatermarkEstimatorName: []int{0, 0},
+	}
+	returnNum := 1 // TODO(BEAM-3301): Enable optional error params in SDF methods.
+
+	watermarkEstimatorT := reflect.TypeOf((*sdf.WatermarkEstimator)(nil)).Elem()
+
+	for _, name := range watermarkEstimationNames {
+		if method, ok := fn.methods[name]; ok {
+			if len(method.Param) < paramRange[name][0] || len(method.Param) > paramRange[name][1] {
+				err := errors.Errorf("unexpected number of params in method %v. got: %v, want number in range: %v to %v",
+					name, len(method.Param), paramRange[name][0], paramRange[name][1])
+				return errors.SetTopLevelMsgf(err, "Unexpected number of parameters in method %v. "+
+					"Got: %v, Want number in range: %v to %v. Check that the signature conforms to the expected signature for %v, "+
+					"and that elements in SDF method parameters match elements in %v.",
+					name, len(method.Param), paramRange[name][0], paramRange[name][1], name, processElementName)

Review Comment:
   That seems like something we can make easier on ourselves (in a later PR), by adding a new function to our errors package so we don't need to repeat ourselves when we want a top level message, but also not lose that info when a higher level sets a top level error....



##########
sdks/go/pkg/beam/core/runtime/exec/sdf.go:
##########
@@ -414,6 +432,10 @@ type SplittableUnit interface {
 	// GetInputId returns the local input ID of the input that the element being
 	// split was received from.
 	GetInputId() string
+
+	// GetOutputWatermark gets the current output watermark of the splittable unit
+	// if one  is defined, or nil otherwise.

Review Comment:
   ```suggestion
   	// if one is defined, or nil otherwise.
   ```



##########
sdks/go/pkg/beam/core/sdf/watermarkEstimator.go:
##########
@@ -0,0 +1,24 @@
+// 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 sdf
+
+import "time"
+
+type WallTimeWatermarkEstimator struct{}

Review Comment:
   Please add documentation strings for exported types.



##########
sdks/go/pkg/beam/core/sdf/watermarkEstimator.go:
##########
@@ -0,0 +1,24 @@
+// 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 sdf
+
+import "time"
+
+type WallTimeWatermarkEstimator struct{}

Review Comment:
   Exported types and methods on those types must have documentation comments.



##########
sdks/go/pkg/beam/core/sdf/watermarkEstimator.go:
##########
@@ -0,0 +1,24 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more

Review Comment:
   WRT the file name, prefer snake_case over lowerCamelCase.
   
   Or simplify the name to estimators.go or watermarks.go and avoid the question entirely.



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