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

Method eval

runtime/vam/expr/mapcall.go:22–60  ·  view source on GitHub ↗
(vecs ...vector.Any)

Source from the content-addressed store, hash-verified

20}
21
22func (m *mapCall) eval(vecs ...vector.Any) vector.Any {
23 if vec, ok := CheckForNullThenError(vecs); ok {
24 return vec
25 }
26 vec := vector.Under(vecs[0])
27 var index []uint32
28 if view, ok := vec.(*vector.View); ok {
29 index = view.Index
30 vec = view.Any
31 }
32 inner, offsets, ok := elements(vec)
33 if !ok {
34 return vector.NewWrappedError(m.sctx, "map: expected array or set value", vecs[0])
35 }
36 inner = m.lambda.Eval(inner)
37 if d, ok := inner.(*vector.Dynamic); ok {
38 var typs []super.Type
39 for _, vec := range d.Values {
40 typs = append(typs, vec.Type())
41 }
42 utyp := m.sctx.LookupTypeUnion(super.UniqueTypes(typs))
43 inner = vector.NewUnion(utyp, d.Tags, d.Values)
44 }
45 var out vector.Any
46 switch vec := vec.(type) {
47 case *vector.Array:
48 typ := m.sctx.LookupTypeArray(inner.Type())
49 out = vector.NewArray(typ, offsets, inner)
50 case *vector.Set:
51 typ := m.sctx.LookupTypeSet(inner.Type())
52 out = vector.NewSet(typ, offsets, inner)
53 default:
54 panic(vec)
55 }
56 if index != nil {
57 out = vector.Pick(out, index)
58 }
59 return out
60}
61
62func elements(vec vector.Any) (vector.Any, []uint32, bool) {
63 switch vec := vec.(type) {

Callers

nothing calls this directly

Calls 14

UnderFunction · 0.92
NewWrappedErrorFunction · 0.92
UniqueTypesFunction · 0.92
NewUnionFunction · 0.92
NewArrayFunction · 0.92
NewSetFunction · 0.92
PickFunction · 0.92
CheckForNullThenErrorFunction · 0.85
elementsFunction · 0.85
LookupTypeUnionMethod · 0.80
LookupTypeArrayMethod · 0.80
LookupTypeSetMethod · 0.80

Tested by

no test coverage detected