import "github.com/apache/beam/sdks/go/pkg/beam/core/typex"
Package typex contains full type representation for PCollections and DoFns, and utilities for type checking.
class.go fulltype.go special.go
var ( TType = reflect.TypeOf((*T)(nil)).Elem() UType = reflect.TypeOf((*U)(nil)).Elem() VType = reflect.TypeOf((*V)(nil)).Elem() WType = reflect.TypeOf((*W)(nil)).Elem() XType = reflect.TypeOf((*X)(nil)).Elem() YType = reflect.TypeOf((*Y)(nil)).Elem() ZType = reflect.TypeOf((*Z)(nil)).Elem() EventTimeType = reflect.TypeOf((*EventTime)(nil)).Elem() WindowType = reflect.TypeOf((*Window)(nil)).Elem() KVType = reflect.TypeOf((*KV)(nil)).Elem() CoGBKType = reflect.TypeOf((*CoGBK)(nil)).Elem() WindowedValueType = reflect.TypeOf((*WindowedValue)(nil)).Elem() )
Bind returns a substitution from universals to types in the given models, such as {"T" -> X, "X" -> int}. Each model must be assignable to the corresponding type. For example, Bind(KV<T,int>, KV<string, int>) would produce {"T" -> string}.
IsBound returns true iff the type has no universal type components. Nodes and coders need bound types.
IsCoGBK returns true iff the type is a CoGBK.
IsComposite returns true iff the given type is one of the predefined Composite marker types: KV, CoGBK or WindowedValue.
IsConcrete returns true iff the given type is a valid "concrete" data type. Such data must be fully serializable. Functions and channels are examples of invalid types. Aggregate types with no universals are considered concrete here.
IsContainer returns true iff the given type is an container data type, such as []int or []T.
IsEqual returns true iff the types are equal.
IsEqualList returns true iff the lists of types are equal.
IsKV returns true iff the type is a KV.
IsList returns true iff the given type is a slice.
IsStructurallyAssignable returns true iff a from value is structurally assignable to the to value of the given types. Types that are "structurally assignable" (SA) are assignable if type variables are disregarded. In other words, depending on the bindings of universal type variables, types may or may not be assignable. However, types that are not SA are not assignable under any bindings.
For example:
SA: KV<int,int> := KV<int,int> SA: KV<int,X> := KV<int,string> // X bound to string by assignment SA: KV<int,string> := KV<int,X> // Assignable only if X is already bound to string SA: KV<int,string> := KV<X,X> // Not assignable under any binding Not SA: KV<int,string> := KV<string,X> Not SA: X := KV<int,string> Not SA: GBK(X,Y) := KV<int,string>
IsUniversal returns true iff the given type is one of the predefined universal types: T, U, V, W, X, Y or Z.
IsW returns true iff the type is a WindowedValue.
Class is the type "class" of data as distinguished by the runtime. The class determines what kind of coding and/or conversion to be inserted. Special types such EventTime, error and reflect.Type are Invalid in this context.
const ( // Invalid type, such as Function, which is not valid as data. Invalid Class = iota // Concrete type, such as int, string, struct { .. }. Concrete // Universal type: T, U, V, W, X, Y, Z. They act as type variables // for type checking purposes, but -- unlike type variables -- are // not instantiated at runtime. Universal // Container type: []. A Go-generic container type that both can be // represented as a reflect.Type and may incur runtime conversions. // The component cannot be a Composite. Container // Composite type: KV, CoGBk, WindowedValue. Beam-generic types // that cannot be represented as a single reflect.Type. Composite )
ClassOf returns the class of a given type. The class is Invalid, if the type is not suitable as data.
type CoGBK struct{}
EventTime is a timestamp that Beam understands as attached to an element.
type FullType interface { // Class returns the class of the FullType. It is never Illegal. Class() Class // Type returns the Go type at the root of the tree, such as KV, X // or int. Type() reflect.Type // Components returns the real components of the root type, if Composite. Components() []FullType }
FullType represents the tree structure of data types processed by the graph. It allows representation of composite types, such as KV<int, string> or W<CoGBK<int, int>>, as well as "generic" such types, KV<int,T> or CoGBK<X,Y>, where the free "type variables" are the fixed universal types: T, X, etc.
New constructs a new full type with the given elements. It panics if not valid.
NewCoGBK constructs a new CoGBK of the given component types.
NewKV constructs a new KV of the given key and value types.
NewW constructs a new WindowedValue of the given type.
SkipK skips the key in a KV layer, if present. If no, returns the input.
SkipW skips a WindowedValue layer, if present. If no, returns the input.
Substitute returns types identical to the given types, but with all universals substituted. All free type variables must be present in the substitution.
type KV struct{}
type T interface{}
type U interface{}
type V interface{}
type W interface{}
type Window interface { // MaxTimestamp returns the the inclusive upper bound of timestamps for values in this window. MaxTimestamp() EventTime // Equals returns true iff the windows are identical. Equals(o Window) bool }
Window represents a concrete Window.
type WindowedValue struct{}
type X interface{}
type Y interface{}
type Z interface{}
Package typex imports 8 packages (graph) and is imported by 21 packages. Updated 2019-10-07. Refresh now. Tools for package owners.