MCPcopy
hub / github.com/dgraph-io/badger / tryAddLevel0Table

Method tryAddLevel0Table

level_handler.go:186–202  ·  view source on GitHub ↗

tryAddLevel0Table returns true if ok and no stalling.

(t *table.Table)

Source from the content-addressed store, hash-verified

184
185// tryAddLevel0Table returns true if ok and no stalling.
186func (s *levelHandler) tryAddLevel0Table(t *table.Table) bool {
187 y.AssertTrue(s.level == 0)
188 // Need lock as we may be deleting the first table during a level 0 compaction.
189 s.Lock()
190 defer s.Unlock()
191 // Return false only if L0 is in memory and number of tables is more than number of
192 // ZeroTableStall. For on disk L0, we should just add the tables to the level.
193 if s.db.opt.KeepL0InMemory && len(s.tables) >= s.db.opt.NumLevelZeroTablesStall {
194 return false
195 }
196
197 s.tables = append(s.tables, t)
198 t.IncrRef()
199 s.totalSize += t.Size()
200
201 return true
202}
203
204func (s *levelHandler) numTables() int {
205 s.RLock()

Callers 2

addLevel0TableMethod · 0.80

Calls 3

AssertTrueFunction · 0.92
IncrRefMethod · 0.45
SizeMethod · 0.45

Tested by 1