beam: github.com/apache/beam/sdks/go/pkg/beam/core/typex Index | Files

package typex

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.

Index

Package Files

class.go fulltype.go special.go

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

func Bind Uses

func Bind(types, models []FullType) (map[string]reflect.Type, error)

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 Uses

func IsBound(t FullType) bool

IsBound returns true iff the type has no universal type components. Nodes and coders need bound types.

func IsCoGBK Uses

func IsCoGBK(t FullType) bool

IsCoGBK returns true iff the type is a CoGBK.

func IsComposite Uses

func IsComposite(t reflect.Type) bool

IsComposite returns true iff the given type is one of the predefined Composite marker types: KV, CoGBK or WindowedValue.

func IsConcrete Uses

func IsConcrete(t reflect.Type) bool

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 Uses

func IsContainer(t reflect.Type) bool

IsContainer returns true iff the given type is an container data type, such as []int or []T.

func IsEqual Uses

func IsEqual(from, to FullType) bool

IsEqual returns true iff the types are equal.

func IsEqualList Uses

func IsEqualList(from, to []FullType) bool

IsEqualList returns true iff the lists of types are equal.

func IsKV Uses

func IsKV(t FullType) bool

IsKV returns true iff the type is a KV.

func IsList Uses

func IsList(t reflect.Type) bool

IsList returns true iff the given type is a slice.

func IsStructurallyAssignable Uses

func IsStructurallyAssignable(from, to FullType) bool

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 Uses

func IsUniversal(t reflect.Type) bool

IsUniversal returns true iff the given type is one of the predefined universal types: T, U, V, W, X, Y or Z.

func IsW Uses

func IsW(t FullType) bool

IsW returns true iff the type is a WindowedValue.

type Class Uses

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
)

func ClassOf Uses

func ClassOf(t reflect.Type) Class

ClassOf returns the class of a given type. The class is Invalid, if the type is not suitable as data.

func (Class) String Uses

func (c Class) String() string

type CoGBK Uses

type CoGBK struct{}

type EventTime Uses

type EventTime = mtime.Time

EventTime is a timestamp that Beam understands as attached to an element.

type FullType Uses

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.

func New Uses

func New(t reflect.Type, components ...FullType) FullType

New constructs a new full type with the given elements. It panics if not valid.

func NewCoGBK Uses

func NewCoGBK(components ...FullType) FullType

NewCoGBK constructs a new CoGBK of the given component types.

func NewKV Uses

func NewKV(components ...FullType) FullType

NewKV constructs a new KV of the given key and value types.

func NewW Uses

func NewW(t FullType) FullType

NewW constructs a new WindowedValue of the given type.

func SkipK Uses

func SkipK(t FullType) FullType

SkipK skips the key in a KV layer, if present. If no, returns the input.

func SkipW Uses

func SkipW(t FullType) FullType

SkipW skips a WindowedValue layer, if present. If no, returns the input.

func Substitute Uses

func Substitute(list []FullType, m map[string]reflect.Type) ([]FullType, error)

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 Uses

type KV struct{}

type T Uses

type T interface{}

type U Uses

type U interface{}

type V Uses

type V interface{}

type W Uses

type W interface{}

type Window Uses

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 Uses

type WindowedValue struct{}

type X Uses

type X interface{}

type Y Uses

type Y interface{}

type Z Uses

type Z interface{}

Package typex imports 8 packages (graph) and is imported by 19 packages. Updated 2019-10-07. Refresh now. Tools for package owners.