table/iterator.go
func (s *ConcatIterator) Seek(key []byte) {
	var idx int
	if !s.reversed {
		idx = sort.Search(len(s.tables), func(i int) bool {
			return y.CompareKeys(s.tables[i].Biggest(), key) >= 0
		})
	} else {
		n := len(s.tables)
		idx = n - 1 - sort.Search(n, func(i int) bool {
			return y.CompareKeys(s.tables[n-1-i].Smallest(), key) <= 0
		})
	}
	if idx >= len(s.tables) || idx < 0 {
		s.setIdx(-1)
		return
	}
	// For reversed=false, we know s.tables[i-1].Biggest() < key. Thus, the
	// previous table cannot possibly contain key.
	s.setIdx(idx)
	s.cur.Seek(key)
}
func (s *ConcatIterator) Seek(key []byte) {
	var idx int
	if !s.reversed {
		idx = sort.Search(len(s.tables), func(i int) bool {
			return y.CompareKeys(s.tables[i].Biggest(), key) >= 0
		})
	} else {
		n := len(s.tables)
		idx = n - 1 - sort.Search(n, func(i int) bool {
			return y.CompareKeys(s.tables[n-1-i].Smallest(), key) <= 0
		})
	}
	if idx >= len(s.tables) || idx < 0 {
		s.setIdx(-1)
		return
	}
	// For reversed=false, we know s.tables[i-1].Biggest() < key. Thus, the
	// previous table cannot possibly contain key.
	s.setIdx(idx)
	s.cur.Seek(key)
}
func ( s * ConcatIterator ) Seek ( key [ ] byte ) { var idx int if ! s . reversed { idx = sort . Search ( len ( s . tables ) , func ( i int ) bool { return y . CompareKeys ( s . tables [ i ] . Biggest ( ) , key ) >= 0 } ) } else { n := len ( s . tables ) idx = n - 1 - sort . Search ( n , func ( i int ) bool { return y . CompareKeys ( s . tables [ n - 1 - i ] . Smallest ( ) , key ) <= 0 } ) } if idx >= len ( s . tables ) || idx < 0 { s . setIdx ( - 1 ) return } // For reversed=false, we know s.tables[i-1].Biggest() < key. Thus, the // previous table cannot possibly contain key. s . setIdx ( idx ) s . cur . Seek ( key ) }
// Seek brings us to element >= key if reversed is false. Otherwise, <= key.
Seek brings us to element > = key if reversed is false . Otherwise < = key .