pub fn near_seek(&mut self, key: &Key, statistics: &mut CFStatistics) -> Result<bool> {
        assert_ne!(self.scan_mode, ScanMode::Backward);
        if !self.iter.valid() {
            return self.seek(key, statistics);
        }
        let ord = self.iter.key().cmp(key.encoded());
        if ord == Ordering::Equal
            || (self.scan_mode == ScanMode::Forward && ord == Ordering::Greater)
        {
            return Ok(true);
        }
        if self.max_key.as_ref().map_or(false, |k| k <= key.encoded()) {
            self.iter.validate_key(key)?;
            return Ok(false);
        }
        if ord == Ordering::Greater {
            near_loop!(
                self.prev(statistics) && self.iter.key() > key.encoded().as_slice(),
                self.seek(key, statistics),
                statistics
            );
            if self.iter.valid() {
                if self.iter.key() < key.encoded().as_slice() {
                    self.next(statistics);
                }
            } else {
                assert!(self.seek_to_first(statistics));
                return Ok(true);
            }
        } else {
            // ord == Less
            near_loop!(
                self.next(statistics) && self.iter.key() < key.encoded().as_slice(),
                self.seek(key, statistics),
                statistics
            );
        }
        if !self.iter.valid() {
            self.max_key = Some(key.encoded().to_owned());
            return Ok(false);
        }
        Ok(true)
    }
/// Seek the specified key.
///
/// This method assume the current position of cursor is
/// around `key`, otherwise you should use `seek` instead.
Seek the specified key.
This method assume the current position of cursor is
around `key`, otherwise you should use `seek` instead.
Seek the specified key . This method assume the current position of cursor is around ` key ` otherwise you should use ` seek ` instead .
pub fn near_seek(&mut self, key: &Key, statistics: &mut CFStatistics) -> Result<bool> {
        assert_ne!(self.scan_mode, ScanMode::Backward);
        if !self.iter.valid() {
            return self.seek(key, statistics);
        }
        let ord = self.iter.key().cmp(key.encoded());
        if ord == Ordering::Equal
            || (self.scan_mode == ScanMode::Forward && ord == Ordering::Greater)
        {
            return Ok(true);
        }
        if self.max_key.as_ref().map_or(false, |k| k <= key.encoded()) {
            self.iter.validate_key(key)?;
            return Ok(false);
        }
        if ord == Ordering::Greater {
            near_loop!(
                self.prev(statistics) && self.iter.key() > key.encoded().as_slice(),
                self.seek(key, statistics),
                statistics
            );
            if self.iter.valid() {
                if self.iter.key() < key.encoded().as_slice() {
                    self.next(statistics);
                }
            } else {
                assert!(self.seek_to_first(statistics));
                return Ok(true);
            }
        } else {
            // ord == Less
            near_loop!(
                self.next(statistics) && self.iter.key() < key.encoded().as_slice(),
                self.seek(key, statistics),
                statistics
            );
        }
        if !self.iter.valid() {
            self.max_key = Some(key.encoded().to_owned());
            return Ok(false);
        }
        Ok(true)
    }
pub fn near_seek ( & mut self , key : & Key , statistics : & mut CFStatistics ) -> Result < bool > { assert_ne ! ( self scan_mode ScanMode Backward ) ; if ! self . iter . valid ( ) { return self . seek ( key , statistics ) ; } let ord = self . iter . key ( ) . cmp ( key . encoded ( ) ) ; if ord == Ordering :: Equal || ( self . scan_mode == ScanMode :: Forward && ord == Ordering :: Greater ) { return Ok ( true ) ; } if self . max_key . as_ref ( ) . map_or ( false , | k | k <= key . encoded ( ) ) { self . iter . validate_key ( key ) ? ; return Ok ( false ) ; } if ord == Ordering :: Greater { near_loop ! ( self prev ( statistics ) self iter key ( ) key encoded ( ) as_slice ( ) self seek ( key statistics ) statistics ) ; if self . iter . valid ( ) { if self . iter . key ( ) < key . encoded ( ) . as_slice ( ) { self . next ( statistics ) ; } } else { assert ! ( self seek_to_first ( statistics ) ) ; return Ok ( true ) ; } } else { // ord == Less near_loop ! ( self next ( statistics ) self iter key ( ) key encoded ( ) as_slice ( ) self seek ( key statistics ) statistics ) ; } if ! self . iter . valid ( ) { self . max_key = Some ( key . encoded ( ) . to_owned ( ) ) ; return Ok ( false ) ; } Ok ( true ) }
Seek the specified key.
Seek the specified key .
&mut self
key
&Key
statistics
&mut CFStatistics