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

Function derefWithNone

runtime/sam/expr/function/cast.go:131–145  ·  view source on GitHub ↗
(typ *super.TypeRecord, bytes scode.Bytes, name string)

Source from the content-addressed store, hash-verified

129}
130
131func derefWithNone(typ *super.TypeRecord, bytes scode.Bytes, name string) (super.Value, bool, bool) {
132 n, ok := typ.IndexOfField(name)
133 if !ok {
134 return super.Value{}, false, false
135 }
136 var elem scode.Bytes
137 var none bool
138 for i, it := 0, scode.NewRecordIter(bytes, typ.Opts); i <= n; i++ {
139 elem, none = it.Next(typ.Fields[i].Opt)
140 }
141 if none {
142 return super.Value{}, true, true
143 }
144 return super.NewValue(typ.Fields[n].Type, elem), true, false
145}
146
147func (c *cast) toArrayOrSet(from super.Value, to super.Type) (super.Value, bool) {
148 fromInner := super.InnerType(from.Type())

Callers 1

toRecordMethod · 0.85

Calls 4

NextMethod · 0.95
NewRecordIterFunction · 0.92
NewValueFunction · 0.92
IndexOfFieldMethod · 0.45

Tested by

no test coverage detected