Documentation ¶
Overview ¶
Package typex contains full type representation for PCollections and DoFns, and utilities for type checking.
Index ¶
- Variables
- func Bind(types, models []FullType) (map[string]reflect.Type, error)
- func IsBound(t FullType) bool
- func IsCoGBK(t FullType) bool
- func IsComposite(t reflect.Type) bool
- func IsConcrete(t reflect.Type) bool
- func IsContainer(t reflect.Type) bool
- func IsEqual(from, to FullType) bool
- func IsEqualList(from, to []FullType) bool
- func IsKV(t FullType) bool
- func IsList(t reflect.Type) bool
- func IsStructurallyAssignable(from, to FullType) bool
- func IsUniversal(t reflect.Type) bool
- func IsW(t FullType) bool
- type Class
- type CoGBK
- type EventTime
- type FullType
- func New(t reflect.Type, components ...FullType) FullType
- func NewCoGBK(components ...FullType) FullType
- func NewKV(components ...FullType) FullType
- func NewW(t FullType) FullType
- func SkipK(t FullType) FullType
- func SkipW(t FullType) FullType
- func Substitute(list []FullType, m map[string]reflect.Type) ([]FullType, error)
- type KV
- type T
- type U
- type V
- type W
- type Window
- type WindowedValue
- type X
- type Y
- type Z
Constants ¶
This section is empty.
Variables ¶
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() )
Functions ¶
func Bind ¶
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}.
func IsBound ¶
IsBound returns true iff the type has no universal type components. Nodes and coders need bound types.
func IsComposite ¶
IsComposite returns true iff the given type is one of the predefined Composite marker types: KV, CoGBK or WindowedValue.
func IsConcrete ¶
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.
func IsContainer ¶
IsContainer returns true iff the given type is an container data type, such as []int or []T.
func IsEqualList ¶
IsEqualList returns true iff the lists of types are equal.
func IsStructurallyAssignable ¶
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>
func IsUniversal ¶
IsUniversal returns true iff the given type is one of the predefined universal types: T, U, V, W, X, Y or Z.
Types ¶
type Class ¶
type Class int
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 )
type FullType ¶
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.
type Window ¶
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 ¶
type WindowedValue struct{}