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/09/13 22:58:03 UTC

[GitHub] [beam] lostluck commented on a diff in pull request #23222: [Go SDK] Add timer coder support

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


##########
sdks/go/pkg/beam/core/runtime/exec/coder.go:
##########
@@ -1208,3 +1213,91 @@ func DecodeWindowedValueHeader(dec WindowDecoder, r io.Reader) ([]typex.Window,
 
 	return ws, t, pn, nil
 }
+
+// EncodeTimer encodes a typex.TimerMap into a byte stream.
+func EncodeTimer(elm ElementEncoder, tm typex.TimerMap, w io.Writer) error {
+	var b bytes.Buffer
+
+	elm.Encode(&FullValue{Elm: tm.Key}, &b)
+
+	if err := coder.EncodeStringUTF8(tm.Tag, &b); err != nil {
+		return errors.WithContext(err, "error encoding tag")
+	}
+
+	if _, err := ioutilx.WriteUnsafe(&b, tm.Windows); err != nil {
+		return err
+	}
+
+	if err := coder.EncodeBool(tm.Clear, &b); err != nil {
+		return errors.WithContext(err, "error encoding key")
+	}
+
+	if !tm.Clear {
+		if err := coder.EncodeVarInt(tm.FireTimestamp, &b); err != nil {

Review Comment:
   VarInt isn't the correct encoding for the FireTimestamp or the HoldTimestamp
   
   See
   https://github.com/apache/beam/blob/master/model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/beam_runner_api.proto#L873
   
   It should be coder.EncodeEventTime instead: https://github.com/apache/beam/blob/master/sdks/go/pkg/beam/core/graph/coder/time.go#L30



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