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/08/30 13:41:07 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #22935: Set state integration test

damccorm commented on code in PR #22935:
URL: https://github.com/apache/beam/pull/22935#discussion_r958497941


##########
sdks/go/test/integration/primitives/state.go:
##########
@@ -385,3 +386,47 @@ func MapStateParDo() *beam.Pipeline {
 
 	return p
 }
+
+type setStateFn struct {
+	State1 state.Set[string]
+}
+
+func (f *setStateFn) ProcessElement(s state.Provider, w string, c int) string {
+	ok, err := f.State1.Contains(s, w)
+	if err != nil {
+		panic(err)
+	}
+	err = f.State1.Add(s, w)
+	if err != nil {
+		panic(err)
+	}
+	if ok {
+		err = f.State1.Add(s, fmt.Sprintf("%v%v", w, 1))
+		if err != nil {
+			panic(err)
+		}
+	}
+
+	keys, _, err := f.State1.Keys(s)
+	if err != nil {
+		panic(err)
+	}
+
+	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
+
+	return fmt.Sprintf("%v: %v, keys: %v", w, ok, keys)
+}
+
+// MapStateParDo tests a DoFn that uses value state.

Review Comment:
   Oop, good catch!



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