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

Method PatchOfPath

db/commits/store.go:369–393  ·  view source on GitHub ↗
(ctx context.Context, base *Snapshot, baseID, commit ksuid.KSUID)

Source from the content-addressed store, hash-verified

367}
368
369func (s *Store) PatchOfPath(ctx context.Context, base *Snapshot, baseID, commit ksuid.KSUID) (*Patch, error) {
370 path, err := s.PathRange(ctx, commit, baseID)
371 if err != nil {
372 return nil, err
373 }
374 patch := NewPatch(base)
375 if len(path) < 2 {
376 // There are no changes past the base. Return the empty patch.
377 return patch, nil
378 }
379 // Play objects in forward order skipping over the last path element
380 // as that is the base and the difference is relative to it.
381 for k := len(path) - 2; k >= 0; k-- {
382 o, err := s.Get(ctx, path[k])
383 if err != nil {
384 return nil, err
385 }
386 for _, action := range o.Actions {
387 if err := PlayAction(patch, action); err != nil {
388 return nil, err
389 }
390 }
391 }
392 return patch, nil
393}
394
395// FindNearestToTs finds the last commit that is greater than or equal to ts.
396func (s *Store) FindNearestToTs(ctx context.Context, tail ksuid.KSUID, ts nano.Ts) (ksuid.KSUID, error) {

Callers 1

buildMergeObjectMethod · 0.80

Calls 4

PathRangeMethod · 0.95
GetMethod · 0.95
NewPatchFunction · 0.85
PlayActionFunction · 0.85

Tested by

no test coverage detected