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

Method recode

runtime/sam/expr/dropper.go:30–66  ·  view source on GitHub ↗
(b *scode.Builder, typ super.Type, bytes scode.Bytes, outType super.Type, dropMap fieldsMap)

Source from the content-addressed store, hash-verified

28}
29
30func (d *Dropper) recode(b *scode.Builder, typ super.Type, bytes scode.Bytes, outType super.Type, dropMap fieldsMap) {
31 recType := super.TypeRecordOf(typ)
32 if recType == nil {
33 b.Append(bytes)
34 return
35 }
36 outRecType := super.TypeUnder(outType).(*super.TypeRecord)
37 var outOff int
38 b.BeginContainer()
39 it := scode.NewRecordIter(bytes, recType.Opts)
40 var optOff int
41 var nones []int
42 for _, f := range recType.Fields {
43 elem, none := it.Next(f.Opt)
44 dropMapChild, ok := dropMap[f.Name]
45 if ok {
46 if dropMapChild == nil {
47 continue
48 }
49 if none {
50 nones = append(nones, optOff)
51 optOff++
52 continue
53 }
54 d.recode(b, f.Type, elem, outRecType.Fields[outOff].Type, dropMapChild)
55 } else if none {
56 nones = append(nones, optOff)
57 } else {
58 b.Append(elem)
59 }
60 if f.Opt {
61 optOff++
62 }
63 outOff++
64 }
65 b.EndContainerWithNones(outRecType.Opts, nones)
66}
67
68func (d *Dropper) Eval(in super.Value) super.Value {
69 typ := in.Type()

Callers 1

EvalMethod · 0.95

Calls 7

NextMethod · 0.95
TypeRecordOfFunction · 0.92
TypeUnderFunction · 0.92
NewRecordIterFunction · 0.92
BeginContainerMethod · 0.80
EndContainerWithNonesMethod · 0.80
AppendMethod · 0.45

Tested by

no test coverage detected