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


##########
sdks/go/test/integration/primitives/state.go:
##########
@@ -126,3 +132,120 @@ func BagStateParDo() *beam.Pipeline {
 
        return p
 }
+
+type combiningStateFn struct {
+       State0 state.Combining[int, int, int]
+       State1 state.Combining[int, int, int]
+       State2 state.Combining[string, string, int]
+       State3 state.Combining[string, string, int]
+       State4 state.Combining[int, int, int]
+}
+
+type combine1 struct{}
+
+func (ac *combine1) MergeAccumulators(a, b int) int {
+       return a + b
+}
+
+type combine2 struct{}
+
+func (ac *combine2) MergeAccumulators(a, b string) string {
+       ai, _ := strconv.Atoi(a)
+       bi, _ := strconv.Atoi(b)
+       return strconv.Itoa(ai + bi)
+}
+
+func (ac *combine2) ExtractOutput(a string) int {
+       ai, _ := strconv.Atoi(a)
+       return ai
+}
+
+type combine3 struct{}
+
+func (ac *combine3) CreateAccumulator() string {
+       return "0"
+}
+
+func (ac *combine3) MergeAccumulators(a string, b string) string {
+       ai, _ := strconv.Atoi(a)
+       bi, _ := strconv.Atoi(b)
+       return strconv.Itoa(ai + bi)
+}
+
+func (ac *combine3) ExtractOutput(a string) int {
+       ai, _ := strconv.Atoi(a)
+       return ai
+}
+
+type combine4 struct{}
+
+func (ac *combine4) AddInput(a, b int) int {
+       return a + b
+}
+
+func (ac *combine4) MergeAccumulators(a, b int) int {
+       return a + b
+}
+
+func (f *combiningStateFn) ProcessElement(s state.Provider, w string, c int) 
string {
+       i, _, err := f.State0.Read(s)
+       if err != nil {
+               panic(err)
+       }
+       err = f.State0.Add(s, 1)
+       if err != nil {
+               panic(err)
+       }
+       i1, _, err := f.State1.Read(s)
+       if err != nil {
+               panic(err)
+       }
+       err = f.State1.Add(s, 1)
+       if err != nil {
+               panic(err)
+       }
+       i2, _, err := f.State2.Read(s)
+       if err != nil {
+               panic(err)
+       }
+       err = f.State2.Add(s, "1")
+       if err != nil {
+               panic(err)
+       }
+       i3, _, err := f.State3.Read(s)
+       if err != nil {
+               panic(err)
+       }
+       err = f.State3.Add(s, "1")
+       if err != nil {
+               panic(err)
+       }
+       i4, _, err := f.State4.Read(s)
+       if err != nil {
+               panic(err)
+       }
+       f.State4.Add(s, 1)

Review Comment:
   missing error handling



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to