initTables replaces s.tables with given tables. This is done during loading.
(tables []*table.Table)
| 53 | |
| 54 | // initTables replaces s.tables with given tables. This is done during loading. |
| 55 | func (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. |
| 80 | func (s *levelHandler) deleteTables(toDel []*table.Table) error { |
no test coverage detected