MCPcopy
hub / github.com/etcd-io/bbolt / loadFreelist

Method loadFreelist

db.go:422–436  ·  view source on GitHub ↗

loadFreelist reads the freelist if it is synced, or reconstructs it by scanning the DB if it is not synced. It assumes there are no concurrent accesses being made to the freelist.

()

Source from the content-addressed store, hash-verified

420// by scanning the DB if it is not synced. It assumes there are no
421// concurrent accesses being made to the freelist.
422func (db *DB) loadFreelist() {
423 db.freelistLoad.Do(func() {
424 db.freelist = newFreelist(db.FreelistType)
425 if !db.hasSyncedFreelist() {
426 // Reconstruct free list by scanning the DB.
427 db.freelist.Init(db.freepages())
428 } else {
429 // Read free list from freelist page.
430 db.freelist.Read(db.page(db.meta().Freelist()))
431 }
432 if db.stats != nil {
433 db.stats.FreePageN = db.freelist.FreeCount()
434 }
435 })
436}
437
438func (db *DB) hasSyncedFreelist() bool {
439 return db.meta().Freelist() != common.PgidNoFreelist

Callers 2

checkMethod · 0.80
OpenFunction · 0.80

Calls 9

hasSyncedFreelistMethod · 0.95
freepagesMethod · 0.95
pageMethod · 0.95
metaMethod · 0.95
newFreelistFunction · 0.85
FreelistMethod · 0.80
InitMethod · 0.65
ReadMethod · 0.65
FreeCountMethod · 0.65

Tested by

no test coverage detected