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

Function buildRecord

sup/builder.go:171–202  ·  view source on GitHub ↗
(b *scode.Builder, val *Record)

Source from the content-addressed store, hash-verified

169}
170
171func buildRecord(b *scode.Builder, val *Record) error {
172 b.BeginContainer()
173 typ := super.TypeUnder(val.Type).(*super.TypeRecord)
174 if nopts := typ.Opts; nopts != 0 {
175 // Set the none bit for each optional field.
176 // We assume the invariant that None occurs only in
177 // optional fields and panic otherwise.
178 nones := make([]byte, (nopts+7)>>3)
179 off := 0
180 for k, v := range val.Fields {
181 if typ.Fields[k].Opt {
182 if _, ok := v.(*None); ok {
183 nones[off>>3] |= 1 << (off & 7)
184 }
185 off++
186 } else if _, ok := v.(*None); ok {
187 panic(v)
188 }
189 }
190 b.Append(nones)
191 }
192 for _, v := range val.Fields {
193 if _, ok := v.(*None); ok {
194 continue
195 }
196 if err := buildValue(b, v); err != nil {
197 return err
198 }
199 }
200 b.EndContainer()
201 return nil
202}
203
204func buildArray(b *scode.Builder, array *Array) error {
205 b.BeginContainer()

Callers 1

buildValueFunction · 0.85

Calls 5

TypeUnderFunction · 0.92
buildValueFunction · 0.85
BeginContainerMethod · 0.80
EndContainerMethod · 0.80
AppendMethod · 0.45

Tested by

no test coverage detected