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/14 13:53:15 UTC

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

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


##########
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:
   Thanks for catching this. The big endian integer got me the other way.



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