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

Function LookupBranchByID

db/api/api.go:153–176  ·  view source on GitHub ↗
(ctx context.Context, api Interface, id ksuid.KSUID)

Source from the content-addressed store, hash-verified

151}
152
153func LookupBranchByID(ctx context.Context, api Interface, id ksuid.KSUID) (*db.BranchMeta, error) {
154 b := newBuffer(db.BranchMeta{})
155 query := fmt.Sprintf("from :branches | branch.id == 'hex(%s)'", idToHex(id))
156 q, err := api.Query(ctx, srcfiles.Plain(query))
157 if err != nil {
158 return nil, err
159 }
160 defer q.Pull(true)
161 if err := vio.Copy(b, q); err != nil {
162 return nil, err
163 }
164 switch len(b.results) {
165 case 0:
166 return nil, fmt.Errorf("%s: branch not found", id)
167 case 1:
168 branch, ok := b.results[0].(*db.BranchMeta)
169 if !ok {
170 return nil, fmt.Errorf("internal error: branch record has wrong type: %T", b.results[0])
171 }
172 return branch, nil
173 default:
174 return nil, fmt.Errorf("internal error: multiple branches found with same id: %s", id)
175 }
176}
177
178func GetCommit(ctx context.Context, api Interface, pool, revision string) (*commits.Commit, error) {
179 poolID, err := api.PoolID(ctx, pool)

Callers

nothing calls this directly

Calls 6

PlainFunction · 0.92
CopyFunction · 0.92
idToHexFunction · 0.85
newBufferFunction · 0.70
QueryMethod · 0.65
PullMethod · 0.65

Tested by

no test coverage detected