MCPcopy Index your code
hub / github.com/dgraph-io/badger / initTables

Method initTables

level_handler.go:55–77  ·  view source on GitHub ↗

initTables replaces s.tables with given tables. This is done during loading.

(tables []*table.Table)

Source from the content-addressed store, hash-verified

53
54// initTables replaces s.tables with given tables. This is done during loading.
55func (s *levelHandler) initTables(tables []*table.Table) {
56 s.Lock()
57 defer s.Unlock()
58
59 s.tables = tables
60 s.totalSize = 0
61 for _, t := range tables {
62 s.totalSize += t.Size()
63 }
64
65 if s.level == 0 {
66 // Key range will overlap. Just sort by fileID in ascending order
67 // because newer tables are at the end of level 0.
68 sort.Slice(s.tables, func(i, j int) bool {
69 return s.tables[i].ID() < s.tables[j].ID()
70 })
71 } else {
72 // Sort tables by keys.
73 sort.Slice(s.tables, func(i, j int) bool {
74 return y.CompareKeys(s.tables[i].Smallest(), s.tables[j].Smallest()) < 0
75 })
76 }
77}
78
79// deleteTables remove tables idx0, ..., idx1-1.
80func (s *levelHandler) deleteTables(toDel []*table.Table) error {

Callers 1

newLevelsControllerFunction · 0.80

Calls 4

CompareKeysFunction · 0.92
IDMethod · 0.80
SmallestMethod · 0.65
SizeMethod · 0.45

Tested by

no test coverage detected