Documentation ¶
Overview ¶
Package state contains structs for reading and manipulating pipeline state.
Index ¶
- Constants
- Variables
- type Bag
- type Combining
- func (s *Combining[T1, T2, T3]) Add(p Provider, val T2) error
- func (s *Combining[T1, T2, T3]) Clear(p Provider) error
- func (s Combining[T1, T2, T3]) CoderType() reflect.Type
- func (s Combining[T1, T2, T3]) GetCombineFn() any
- func (s Combining[T1, T2, T3]) KeyCoderType() reflect.Type
- func (s *Combining[T1, T2, T3]) Read(p Provider) (T3, bool, error)
- func (s Combining[T1, T2, T3]) StateKey() string
- func (s Combining[T1, T2, T3]) StateType() TypeEnum
- type CombiningPipelineState
- type Map
- func (s *Map[K, V]) Clear(p Provider) error
- func (s Map[K, V]) CoderType() reflect.Type
- func (s *Map[K, V]) Get(p Provider, key K) (V, bool, error)
- func (s Map[K, V]) KeyCoderType() reflect.Type
- func (s *Map[K, V]) Keys(p Provider) ([]K, bool, error)
- func (s *Map[K, V]) Put(p Provider, key K, val V) error
- func (s *Map[K, V]) Remove(p Provider, key K) error
- func (s Map[K, V]) StateKey() string
- func (s Map[K, V]) StateType() TypeEnum
- type PipelineState
- type Provider
- type Set
- func (s *Set[K]) Add(p Provider, key K) error
- func (s Set[K]) Clear(p Provider) error
- func (s Set[K]) CoderType() reflect.Type
- func (s *Set[K]) Contains(p Provider, key K) (bool, error)
- func (s Set[K]) KeyCoderType() reflect.Type
- func (s *Set[K]) Keys(p Provider) ([]K, bool, error)
- func (s Set[K]) Remove(p Provider, key K) error
- func (s Set[K]) StateKey() string
- func (s Set[K]) StateType() TypeEnum
- type Transaction
- type TransactionTypeEnum
- type TypeEnum
- type Value
- func (s *Value[T]) Clear(p Provider) error
- func (s Value[T]) CoderType() reflect.Type
- func (s Value[T]) KeyCoderType() reflect.Type
- func (s *Value[T]) Read(p Provider) (T, bool, error)
- func (s Value[T]) StateKey() string
- func (s Value[T]) StateType() TypeEnum
- func (s *Value[T]) Write(p Provider, val T) error
Constants ¶
const ( // TransactionTypeSet is the set transaction type TransactionTypeSet TransactionTypeEnum = 0 // TransactionTypeClear is the set transaction type TransactionTypeClear TransactionTypeEnum = 1 // TransactionTypeAppend is the append transaction type TransactionTypeAppend TransactionTypeEnum = 2 // TypeValue represents a value state TypeValue TypeEnum = 0 // TypeBag represents a bag state TypeBag TypeEnum = 1 // TypeCombining represents a combining state TypeCombining TypeEnum = 2 // TypeMap represents a map state TypeMap TypeEnum = 3 // TypeSet represents a set state TypeSet TypeEnum = 4 )
Variables ¶
var ( // ProviderType is the state provider type ProviderType = reflect.TypeOf((*Provider)(nil)).Elem() )
Functions ¶
This section is empty.
Types ¶
type Bag ¶
Bag is used to read and write global pipeline state representing a collection of values. Key represents the key used to lookup this state.
func MakeBagState ¶
MakeBagState is a factory function to create an instance of BagState with the given key.
func (*Bag[T]) Clear ¶
Clear is used to clear this instance of global pipeline state representing a bag.
func (Bag[T]) CoderType ¶
CoderType returns the type of the bag state which should be used for a coder.
func (Bag[T]) KeyCoderType ¶
KeyCoderType returns nil since Bag types aren't keyed.
func (*Bag[T]) Read ¶
Read is used to read this instance of global pipeline state representing a bag. When a value is not found, returns an empty list and false.
type Combining ¶
Combining is used to read and write global pipeline state representing a single combined value. It uses 3 generic values, [T1, T2, T3], to represent the accumulator, input, and output types respectively. Key represents the key used to lookup this state.
func MakeCombiningState ¶
MakeCombiningState is a factory function to create an instance of Combining state with the given key and combiner when the combiner may have different types for its accumulator, input, and output. Takes 3 generic constraints [T1, T2, T3 any] representing the accumulator/input/output types respectively. If no accumulator or output types are defined, use the input type.
func (*Combining[T1, T2, T3]) Add ¶
Add is used to write add an element to the combining pipeline state.
func (*Combining[T1, T2, T3]) Clear ¶
Clear is used to clear this instance of global pipeline state representing a combiner.
func (Combining[T1, T2, T3]) CoderType ¶
CoderType returns the type of the bag state which should be used for a coder.
func (Combining[T1, T2, T3]) GetCombineFn ¶
GetCombineFn returns this state instance's CombineFn
func (Combining[T1, T2, T3]) KeyCoderType ¶
KeyCoderType returns nil since combining state types aren't keyed.
func (*Combining[T1, T2, T3]) Read ¶
Read is used to read this instance of global pipeline state representing a combiner. When a value is not found, returns an empty list and false.
type CombiningPipelineState ¶
type CombiningPipelineState interface {
GetCombineFn() any
}
CombiningPipelineState is an interface representing combining pipeline state. It is primarily meant for Beam packages to use and is probably not useful for most pipeline authors.
type Map ¶
type Map[K comparable, V any] struct { Key string }
Map is used to read and write global pipeline state representing a map. Key represents the key used to lookup this state (not the key of map entries).
func MakeMapState ¶
func MakeMapState[K comparable, V any](k string) Map[K, V]
MakeMapState is a factory function to create an instance of MapState with the given key.
func (Map[K, V]) CoderType ¶
CoderType returns the type of the value state which should be used for a coder for map values.
func (*Map[K, V]) Get ¶
Get is used to read a value given a key. When a value is not found, returns the 0 value and false.
func (Map[K, V]) KeyCoderType ¶
KeyCoderType returns the type of the value state which should be used for a coder for map keys.
func (*Map[K, V]) Keys ¶
Keys is used to read the keys of this map state. When a value is not found, returns an empty list and false.
type PipelineState ¶
type PipelineState interface { StateKey() string KeyCoderType() reflect.Type CoderType() reflect.Type StateType() TypeEnum }
PipelineState is an interface representing different kinds of PipelineState (currently just state.Value). It is primarily meant for Beam packages to use and is probably not useful for most pipeline authors.
type Provider ¶
type Provider interface { ReadValueState(id string) (any, []Transaction, error) WriteValueState(val Transaction) error ClearValueState(val Transaction) error ReadBagState(id string) ([]any, []Transaction, error) WriteBagState(val Transaction) error ClearBagState(val Transaction) error CreateAccumulatorFn(userStateID string) reflectx.Func AddInputFn(userStateID string) reflectx.Func MergeAccumulatorsFn(userStateID string) reflectx.Func ExtractOutputFn(userStateID string) reflectx.Func ReadMapStateValue(userStateID string, key any) (any, []Transaction, error) ReadMapStateKeys(userStateID string) ([]any, []Transaction, error) WriteMapState(val Transaction) error ClearMapStateKey(val Transaction) error ClearMapState(val Transaction) error }
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 Set ¶
type Set[K comparable] struct { Key string }
Set is used to read and write global pipeline state representing a Set. Key represents the key used to lookup this state (not the key of Set entries).
func MakeSetState ¶
func MakeSetState[K comparable](k string) Set[K]
MakeSetState is a factory function to create an instance of SetState with the given key.
func (Set[K]) CoderType ¶
CoderType returns the type of the coder used for values, in this case nil since there are no values associated with a set.
func (Set[K]) KeyCoderType ¶
KeyCoderType returns the type of the value state which should be used for a coder for set keys.
func (*Set[K]) Keys ¶
Keys is used to read the keys of this set state. When a value is not found, returns an empty list and false.
type Transaction ¶
type Transaction struct { Key string Type TransactionTypeEnum MapKey any Val any }
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 TransactionTypeEnum ¶
type TransactionTypeEnum int32
TransactionTypeEnum represents the type of state transaction (e.g. set, clear)
type TypeEnum ¶
type TypeEnum int32
TypeEnum represents the type of a state instance (e.g. value, bag, etc...)
type Value ¶
Value is used to read and write global pipeline state representing a single value. Key represents the key used to lookup this state.
func MakeValueState ¶
MakeValueState is a factory function to create an instance of ValueState with the given key.
func (*Value[T]) Clear ¶
Clear is used to clear this instance of global pipeline state representing a single value.
func (Value[T]) CoderType ¶
CoderType returns the type of the value state which should be used for a coder.
func (Value[T]) KeyCoderType ¶
KeyCoderType returns nil since Value types aren't keyed.
func (*Value[T]) Read ¶
Read is used to read this instance of global pipeline state representing a single value. When a value is not found, returns the 0 value and false.