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

Method formatRecord

sup/formatter.go:412–447  ·  view source on GitHub ↗
(indent int, typ *super.TypeRecord, bytes scode.Bytes, known bool)

Source from the content-addressed store, hash-verified

410}
411
412func (f *Formatter) formatRecord(indent int, typ *super.TypeRecord, bytes scode.Bytes, known bool) {
413 f.build("{")
414 if len(typ.Fields) == 0 {
415 f.build("}")
416 return
417 }
418 indent += f.tab
419 sep := f.newline
420 it := scode.NewRecordIter(bytes, typ.Opts)
421 for _, field := range typ.Fields {
422 f.build(sep)
423 f.startColor(color.Blue)
424 f.indent(indent, QuotedName(field.Name))
425 if field.Opt {
426 f.build("?")
427 }
428 f.endColor()
429 f.build(":")
430 if f.tab > 0 {
431 f.build(" ")
432 }
433 elem, none := it.Next(field.Opt)
434 if none {
435 f.build("_")
436 f.startColor(color.Gray(200))
437 f.build("::")
438 f.formatType(field.Type, true)
439 f.endColor()
440 } else {
441 f.formatValue(indent, field.Type, elem, known, true)
442 }
443 sep = "," + f.newline
444 }
445 f.build(f.newline)
446 f.indent(indent-f.tab, "}")
447}
448
449func (f *Formatter) formatVector(indent int, open, close string, inner super.Type, val super.Value, known bool) bool {
450 f.build(open)

Callers 1

formatValueMethod · 0.95

Calls 10

buildMethod · 0.95
startColorMethod · 0.95
indentMethod · 0.95
endColorMethod · 0.95
NextMethod · 0.95
formatTypeMethod · 0.95
formatValueMethod · 0.95
NewRecordIterFunction · 0.92
GrayFunction · 0.92
QuotedNameFunction · 0.85

Tested by

no test coverage detected