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

Method Vacuum

db/pool.go:285–335  ·  view source on GitHub ↗
(ctx context.Context, commit ksuid.KSUID, dryrun bool)

Source from the content-addressed store, hash-verified

283}
284
285func (p *Pool) Vacuum(ctx context.Context, commit ksuid.KSUID, dryrun bool) ([]ksuid.KSUID, error) {
286 group, ctx := errgroup.WithContext(ctx)
287 group.SetLimit(runtime.GOMAXPROCS(0))
288 ch := make(chan *data.Object)
289 group.Go(func() error {
290 defer close(ch)
291 return p.commits.Vacuumable(ctx, commit, ch)
292 })
293 var vacuumed []ksuid.KSUID
294 var mu sync.Mutex
295 for o := range ch {
296 if dryrun {
297 // For dryrun just check if the object exists and append existing
298 // objects to list of results.
299 group.Go(func() error {
300 ok, err := p.engine.Exists(ctx, data.SequenceURI(p.DataPath, o.ID))
301 if ok {
302 mu.Lock()
303 vacuumed = append(vacuumed, o.ID)
304 mu.Unlock()
305 }
306 return err
307 })
308 continue
309 }
310 group.Go(func() error {
311 err := p.engine.Delete(ctx, data.SequenceURI(p.DataPath, o.ID))
312 if err == nil {
313 mu.Lock()
314 vacuumed = append(vacuumed, o.ID)
315 mu.Unlock()
316 }
317 if errors.Is(err, fs.ErrNotExist) {
318 err = nil
319 }
320 return err
321 })
322 // Delete the seek index as well.
323 group.Go(func() error {
324 err := p.engine.Delete(ctx, data.SeekIndexURI(p.DataPath, o.ID))
325 if errors.Is(err, fs.ErrNotExist) {
326 err = nil
327 }
328 return err
329 })
330 }
331 if err := group.Wait(); err != nil {
332 return nil, err
333 }
334 return vacuumed, nil
335}
336
337func (p *Pool) Main(ctx context.Context) (BranchMeta, error) {
338 branch, err := p.OpenBranchByName(ctx, "main")

Callers

nothing calls this directly

Calls 8

SequenceURIFunction · 0.92
SeekIndexURIFunction · 0.92
closeFunction · 0.85
VacuumableMethod · 0.80
IsMethod · 0.80
ExistsMethod · 0.65
DeleteMethod · 0.65
WaitMethod · 0.45

Tested by

no test coverage detected