level_handler.go
func (s *levelHandler) initTables(tables []*table.Table) {
	s.Lock()
	defer s.Unlock()

	s.tables = tables
	s.totalSize = 0
	for _, t := range tables {
		s.totalSize += t.Size()
	}

	if s.level == 0 {
		// Key range will overlap. Just sort by fileID in ascending order
		// because newer tables are at the end of level 0.
		sort.Slice(s.tables, func(i, j int) bool {
			return s.tables[i].ID() < s.tables[j].ID()
		})
	} else {
		// Sort tables by keys.
		sort.Slice(s.tables, func(i, j int) bool {
			return y.CompareKeys(s.tables[i].Smallest(), s.tables[j].Smallest()) < 0
		})
	}
}
func (s *levelHandler) initTables(tables []*table.Table) {
	s.Lock()
	defer s.Unlock()

	s.tables = tables
	s.totalSize = 0
	for _, t := range tables {
		s.totalSize += t.Size()
	}

	if s.level == 0 {
		// Key range will overlap. Just sort by fileID in ascending order
		// because newer tables are at the end of level 0.
		sort.Slice(s.tables, func(i, j int) bool {
			return s.tables[i].ID() < s.tables[j].ID()
		})
	} else {
		// Sort tables by keys.
		sort.Slice(s.tables, func(i, j int) bool {
			return y.CompareKeys(s.tables[i].Smallest(), s.tables[j].Smallest()) < 0
		})
	}
}
func ( s * levelHandler ) initTables ( tables [ ] * table . Table ) { s . Lock ( ) defer s . Unlock ( ) s . tables = tables s . totalSize = 0 for _ , t := range tables { s . totalSize += t . Size ( ) } if s . level == 0 { // Key range will overlap. Just sort by fileID in ascending order // because newer tables are at the end of level 0. sort . Slice ( s . tables , func ( i , j int ) bool { return s . tables [ i ] . ID ( ) < s . tables [ j ] . ID ( ) } ) } else { // Sort tables by keys. sort . Slice ( s . tables , func ( i , j int ) bool { return y . CompareKeys ( s . tables [ i ] . Smallest ( ) , s . tables [ j ] . Smallest ( ) ) < 0 } ) } }
// initTables replaces s.tables with given tables. This is done during loading.
initTables replaces s . tables with given tables . This is done during loading .