pub fn near_seek_for_prev(&mut self, key: &Key, statistics: &mut CFStatistics) -> Result<bool> {
        assert_ne!(self.scan_mode, ScanMode::Forward);
        if !self.iter.valid() {
            return self.seek_for_prev(key, statistics);
        }
        let ord = self.iter.key().cmp(key.encoded());
        if ord == Ordering::Equal || (self.scan_mode == ScanMode::Backward && ord == Ordering::Less)
        {
            return Ok(true);
        }

        if self.min_key.as_ref().map_or(false, |k| k >= key.encoded()) {
            self.iter.validate_key(key)?;
            return Ok(false);
        }

        if ord == Ordering::Less {
            near_loop!(
                self.next(statistics) && self.iter.key() < key.encoded().as_slice(),
                self.seek_for_prev(key, statistics),
                statistics
            );
            if self.iter.valid() {
                if self.iter.key() > key.encoded().as_slice() {
                    self.prev(statistics);
                }
            } else {
                assert!(self.seek_to_last(statistics));
                return Ok(true);
            }
        } else {
            near_loop!(
                self.prev(statistics) && self.iter.key() > key.encoded().as_slice(),
                self.seek_for_prev(key, statistics),
                statistics
            );
        }

        if !self.iter.valid() {
            self.min_key = Some(key.encoded().to_owned());
            return Ok(false);
        }
        Ok(true)
    }
/// Find the largest key that is not greater than the specific key.
Find the largest key that is not greater than the specific key.
Find the largest key that is not greater than the specific key .
pub fn near_seek_for_prev(&mut self, key: &Key, statistics: &mut CFStatistics) -> Result<bool> {
        assert_ne!(self.scan_mode, ScanMode::Forward);
        if !self.iter.valid() {
            return self.seek_for_prev(key, statistics);
        }
        let ord = self.iter.key().cmp(key.encoded());
        if ord == Ordering::Equal || (self.scan_mode == ScanMode::Backward && ord == Ordering::Less)
        {
            return Ok(true);
        }
        if self.min_key.as_ref().map_or(false, |k| k >= key.encoded()) {
            self.iter.validate_key(key)?;
            return Ok(false);
        }
        if ord == Ordering::Less {
            near_loop!(
                self.next(statistics) && self.iter.key() < key.encoded().as_slice(),
                self.seek_for_prev(key, statistics),
                statistics
            );
            if self.iter.valid() {
                if self.iter.key() > key.encoded().as_slice() {
                    self.prev(statistics);
                }
            } else {
                assert!(self.seek_to_last(statistics));
                return Ok(true);
            }
        } else {
            near_loop!(
                self.prev(statistics) && self.iter.key() > key.encoded().as_slice(),
                self.seek_for_prev(key, statistics),
                statistics
            );
        }
        if !self.iter.valid() {
            self.min_key = Some(key.encoded().to_owned());
            return Ok(false);
        }
        Ok(true)
    }
pub fn near_seek_for_prev ( & mut self , key : & Key , statistics : & mut CFStatistics ) -> Result < bool > { assert_ne ! ( self scan_mode ScanMode Forward ) ; if ! self . iter . valid ( ) { return self . seek_for_prev ( key , statistics ) ; } let ord = self . iter . key ( ) . cmp ( key . encoded ( ) ) ; if ord == Ordering :: Equal || ( self . scan_mode == ScanMode :: Backward && ord == Ordering :: Less ) { return Ok ( true ) ; } if self . min_key . as_ref ( ) . map_or ( false , | k | k >= key . encoded ( ) ) { self . iter . validate_key ( key ) ? ; return Ok ( false ) ; } if ord == Ordering :: Less { near_loop ! ( self next ( statistics ) self iter key ( ) key encoded ( ) as_slice ( ) self seek_for_prev ( key statistics ) statistics ) ; if self . iter . valid ( ) { if self . iter . key ( ) > key . encoded ( ) . as_slice ( ) { self . prev ( statistics ) ; } } else { assert ! ( self seek_to_last ( statistics ) ) ; return Ok ( true ) ; } } else { near_loop ! ( self prev ( statistics ) self iter key ( ) key encoded ( ) as_slice ( ) self seek_for_prev ( key statistics ) statistics ) ; } if ! self . iter . valid ( ) { self . min_key = Some ( key . encoded ( ) . to_owned ( ) ) ; return Ok ( false ) ; } Ok ( true ) }
Find the largest key that is not greater than the specific key.
Find the largest key that is not greater than the specific key .
&mut self
key
&Key
statistics
&mut CFStatistics