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

Method Call

runtime/vam/expr/function/fields.go:24–61  ·  view source on GitHub ↗
(args ...vector.Any)

Source from the content-addressed store, hash-verified

22}
23
24func (f *Fields) Call(args ...vector.Any) vector.Any {
25 if vec, ok := expr.CheckForNullThenError(args); ok {
26 return vec
27 }
28 val := vector.Under(args[0])
29 switch typ := val.Type().(type) {
30 case *super.TypeRecord:
31 paths := buildPath(typ, nil)
32 s := vector.NewStringEmpty(val.Len())
33 inOffs, outOffs := []uint32{0}, []uint32{0}
34 for i := uint32(0); i < val.Len(); i++ {
35 inOffs, outOffs = appendPaths(paths, s, inOffs, outOffs)
36 }
37 inner := vector.NewArray(f.innerTyp, inOffs, s)
38 return vector.NewArray(f.outerTyp, outOffs, inner)
39 case *super.TypeOfType:
40 var errs []uint32
41 s := vector.NewStringEmpty(val.Len())
42 inOffs, outOffs := []uint32{0}, []uint32{0}
43 for i := uint32(0); i < val.Len(); i++ {
44 b := vector.TypeValueValue(val, i)
45 rtyp := f.recordType(b)
46 if rtyp == nil {
47 errs = append(errs, i)
48 continue
49 }
50 inOffs, outOffs = appendPaths(buildPath(rtyp, nil), s, inOffs, outOffs)
51 }
52 inner := vector.NewArray(f.innerTyp, inOffs, s)
53 out := vector.NewArray(f.outerTyp, outOffs, inner)
54 if len(errs) > 0 {
55 return vector.Combine(out, errs, vector.NewStringError(f.sctx, "missing", uint32(len(errs))))
56 }
57 return out
58 default:
59 return vector.NewStringError(f.sctx, "missing", val.Len())
60 }
61}
62
63func (f *Fields) recordType(b []byte) *super.TypeRecord {
64 typ, err := f.sctx.LookupByValue(b)

Callers

nothing calls this directly

Calls 12

recordTypeMethod · 0.95
CheckForNullThenErrorFunction · 0.92
UnderFunction · 0.92
NewStringEmptyFunction · 0.92
NewArrayFunction · 0.92
TypeValueValueFunction · 0.92
CombineFunction · 0.92
NewStringErrorFunction · 0.92
appendPathsFunction · 0.85
buildPathFunction · 0.70
TypeMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected