MCPcopy Create free account
hub / github.com/brimdata/super / unify

Method unify

runtime/sam/expr/function/unblend.go:95–118  ·  view source on GitHub ↗
(elems []super.Value)

Source from the content-addressed store, hash-verified

93}
94
95func (u *unblend) unify(elems []super.Value) (super.Type, scode.Bytes) {
96 seen := make(map[super.Type]struct{})
97 var types []super.Type
98 for _, e := range elems {
99 typ := e.Type()
100 if _, ok := seen[typ]; !ok {
101 seen[typ] = struct{}{}
102 types = append(types, typ)
103 }
104 }
105 if len(types) == 1 {
106 var b scode.Builder
107 for _, e := range elems {
108 b.Append(e.Bytes())
109 }
110 return types[0], b.Bytes()
111 }
112 var b scode.Builder
113 union := u.sctx.LookupTypeUnion(types)
114 for _, e := range elems {
115 super.BuildUnion(&b, union.TagOf(e.Type()), e.Bytes())
116 }
117 return union, b.Bytes()
118}
119
120func (u *unblend) unifyType(vals []super.Value) super.Type {
121 seen := make(map[super.Type]struct{})

Callers 1

evalMethod · 0.95

Calls 7

AppendMethod · 0.95
BytesMethod · 0.95
BuildUnionFunction · 0.92
LookupTypeUnionMethod · 0.80
TagOfMethod · 0.80
TypeMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected