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

Method validate

util.go:41–68  ·  view source on GitHub ↗

Check does some sanity check on one level of data or in-memory index.

()

Source from the content-addressed store, hash-verified

39
40// Check does some sanity check on one level of data or in-memory index.
41func (s *levelHandler) validate() error {
42 if s.level == 0 {
43 return nil
44 }
45
46 s.RLock()
47 defer s.RUnlock()
48 numTables := len(s.tables)
49 for j := 1; j < numTables; j++ {
50 if j >= len(s.tables) {
51 return errors.Errorf("Level %d, j=%d numTables=%d", s.level, j, numTables)
52 }
53
54 if y.CompareKeys(s.tables[j-1].Biggest(), s.tables[j].Smallest()) >= 0 {
55 return errors.Errorf(
56 "Inter: Biggest(j-1) \n%s\n vs Smallest(j): \n%s\n: level=%d j=%d numTables=%d",
57 hex.Dump(s.tables[j-1].Biggest()), hex.Dump(s.tables[j].Smallest()),
58 s.level, j, numTables)
59 }
60
61 if y.CompareKeys(s.tables[j].Smallest(), s.tables[j].Biggest()) > 0 {
62 return errors.Errorf(
63 "Intra: \n%s\n vs \n%s\n: level=%d j=%d numTables=%d",
64 hex.Dump(s.tables[j].Smallest()), hex.Dump(s.tables[j].Biggest()), s.level, j, numTables)
65 }
66 }
67 return nil
68}
69
70// func (s *KV) debugPrintMore() { s.lc.debugPrintMore() }
71

Callers 1

validateMethod · 0.45

Calls 4

CompareKeysFunction · 0.92
ErrorfMethod · 0.65
BiggestMethod · 0.65
SmallestMethod · 0.65

Tested by

no test coverage detected