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

Function derefWithNoneAndOk

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

Source from the content-addressed store, hash-verified

108}
109
110func derefWithNoneAndOk(typ *super.TypeRecord, bytes scode.Bytes, name string) (super.Type, scode.Bytes, bool, bool) {
111 n, ok := typ.IndexOfField(name)
112 if !ok {
113 return nil, nil, false, false
114 }
115 var elem scode.Bytes
116 var none bool
117 for i, it := 0, scode.NewRecordIter(bytes, typ.Opts); i <= n; i++ {
118 elem, none = it.Next(typ.Fields[i].Opt)
119 }
120 fieldType := typ.Fields[n].Type
121 if none {
122 return fieldType, nil, true, true
123 }
124 return fieldType, elem, false, true
125
126}
127
128func (u *Upcast) toArray(b *scode.Builder, typ super.Type, bytes scode.Bytes, to *super.TypeArray) bool {
129 if arrayType, ok := typ.(*super.TypeArray); ok {

Callers 2

toRecordMethod · 0.85
toRecordMethod · 0.85

Calls 3

NextMethod · 0.95
NewRecordIterFunction · 0.92
IndexOfFieldMethod · 0.45

Tested by

no test coverage detected