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

Method SetBase

db/commits/store.go:418–439  ·  view source on GitHub ↗

SetBase establishes a new base (snapshot) at the provided commit and resets the attached caches, then deletes all prior commits.

(ctx context.Context, commit ksuid.KSUID)

Source from the content-addressed store, hash-verified

416// SetBase establishes a new base (snapshot) at the provided commit and resets
417// the attached caches, then deletes all prior commits.
418func (s *Store) SetBase(ctx context.Context, commit ksuid.KSUID) ([]ksuid.KSUID, error) {
419 path, err := s.Path(ctx, commit)
420 if err != nil {
421 return nil, err
422 }
423 if len(path) <= 1 {
424 return nil, errors.New("cannot set base on earliest commit")
425 }
426 // Create snapshot of previous commit.
427 snap, err := s.buildSnapshot(ctx, path[1])
428 if err != nil {
429 return nil, err
430 }
431 if err := s.putBase(ctx, snap, path[1]); err != nil {
432 return nil, err
433 }
434 s.cache.Purge()
435 s.paths.Purge()
436 s.snapshots.Purge()
437 s.snapshots.Add(path[1], snap)
438 return path[1:], s.deletePath(ctx, path[1:])
439}
440
441// DANGER ZONE - commits should only be removed once a new base has been
442// established.

Callers 1

vacateCommitsMethod · 0.80

Calls 6

PathMethod · 0.95
buildSnapshotMethod · 0.95
putBaseMethod · 0.95
deletePathMethod · 0.95
NewMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected