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

Function addPath

vector/recordbuilder.go:35–57  ·  view source on GitHub ↗
(r *rec, path field.Path)

Source from the content-addressed store, hash-verified

33}
34
35func addPath(r *rec, path field.Path) error {
36 for k, name := range path {
37 idx := slices.Index(r.paths, name)
38 if k == len(path)-1 {
39 if idx > -1 {
40 return &super.DuplicateFieldError{Name: path.String()}
41 }
42 r.paths = append(r.paths, path[k])
43 r.recs = append(r.recs, nil)
44 return nil
45 }
46 if idx == -1 {
47 idx = len(r.paths)
48 r.paths = append(r.paths, name)
49 r.recs = append(r.recs, &rec{})
50 }
51 if r.recs[idx] == nil {
52 return &super.DuplicateFieldError{Name: path[:k+1].String()}
53 }
54 r = r.recs[idx]
55 }
56 return nil
57}
58
59func (r *rec) build(sctx *super.Context, leafs []Any) (*Record, []Any) {
60 var fields []super.Field

Callers 1

NewRecordBuilderFunction · 0.85

Calls 2

IndexMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected