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/17 20:43:07 UTC

[GitHub] [beam] riteshghorse commented on a diff in pull request #22761: Go stateful DoFns user side changes

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


##########
sdks/go/pkg/beam/core/funcx/fn.go:
##########
@@ -374,6 +390,8 @@ func New(fn reflectx.Func) (*Fn, error) {
 			kind = FnWindow
 		case t == typex.BundleFinalizationType:
 			kind = FnBundleFinalization
+		case t == state.ProviderType:

Review Comment:
   Should we have the types for state and timers defined in typex package? I was thinking this for timers as well.



##########
sdks/go/pkg/beam/core/state/state.go:
##########
@@ -0,0 +1,117 @@
+// 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 state contains structs for reading and manipulating pipeline state.
+package state
+
+import (
+	"reflect"
+)
+
+type TransactionType_Enum int32
+
+const (
+	TransactionType_Set   TransactionType_Enum = 0
+	TransactionType_Clear TransactionType_Enum = 1
+)
+
+var (
+	ProviderType = reflect.TypeOf((*Provider)(nil)).Elem()
+)
+
+// TODO(#20510) - add other forms of state (MapState, BagState, CombiningState), prefetch, and clear.
+
+// Transaction is used to represent a pending state transaction. This should not be manipulated directly;
+// it is primarily used for implementations of the Provider interface to talk to the various State objects.
+type Transaction struct {
+	Key  string
+	Type TransactionType_Enum
+	Val  interface{}
+}
+
+// Provider represents the DoFn parameter used to get and manipulate pipeline state
+// stored as key value pairs (https://beam.apache.org/documentation/programming-guide/#state-and-timers).
+// This should not be manipulated directly. Instead it should be used as a parameter
+// to functions on State objects like state.Value.
+type Provider interface {
+	ReadValueState(id string) (interface{}, []Transaction, error)
+	WriteValueState(val Transaction) error
+}
+
+type PipelineState interface {

Review Comment:
   Doc comment. Also fine if you are planning to add it in next PRs.



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