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

Method Eval

runtime/sam/expr/map.go:24–49  ·  view source on GitHub ↗
(in super.Value)

Source from the content-addressed store, hash-verified

22}
23
24func (a *mapCall) Eval(in super.Value) super.Value {
25 val := a.eval.Eval(in)
26 if val.IsNull() || val.IsError() {
27 return val
28 }
29 elems, err := val.Elements()
30 if err != nil {
31 return a.sctx.WrapError("map: expected array or set value", in)
32 }
33 if len(elems) == 0 {
34 return val
35 }
36 a.vals = a.vals[:0]
37 a.types = a.types[:0]
38 for _, elem := range elems {
39 val := a.lambda.Eval(elem)
40 a.vals = append(a.vals, val)
41 a.types = append(a.types, val.Type())
42 }
43 inner := a.innerType(a.types)
44 bytes := a.buildVal(inner)
45 if _, ok := super.TypeUnder(val.Type()).(*super.TypeSet); ok {
46 return super.NewValue(a.sctx.LookupTypeSet(inner), super.NormalizeSet(bytes))
47 }
48 return super.NewValue(a.sctx.LookupTypeArray(inner), bytes)
49}
50
51func (a *mapCall) buildVal(inner super.Type) []byte {
52 a.builder.Reset()

Callers

nothing calls this directly

Calls 13

innerTypeMethod · 0.95
buildValMethod · 0.95
TypeUnderFunction · 0.92
NewValueFunction · 0.92
NormalizeSetFunction · 0.92
IsNullMethod · 0.80
IsErrorMethod · 0.80
ElementsMethod · 0.80
WrapErrorMethod · 0.80
LookupTypeSetMethod · 0.80
LookupTypeArrayMethod · 0.80
EvalMethod · 0.65

Tested by

no test coverage detected