File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -599,6 +599,16 @@ pub type KvFuture<Resp> = Box<dyn Future<Item = Resp, Error = Error>>;
599
599
/// which means all of the above types can be passed directly to those functions.
600
600
pub trait KeyRange : Sized {
601
601
fn into_bounds ( self ) -> ( Bound < Key > , Bound < Key > ) ;
602
+ /// Return the keys that match the given bounds, inclusively.
603
+ ///
604
+ /// ```rust
605
+ /// use tikv_client::{KeyRange, Key};
606
+ /// let range = vec![0]..vec![100];
607
+ /// assert_eq!(
608
+ /// range.into_keys().unwrap(),
609
+ /// (Key::from(vec![0]), Some(Key::from(vec![99])))
610
+ /// );
611
+ // ```
602
612
fn into_keys ( self ) -> Result < ( Key , Option < Key > ) > {
603
613
range_to_keys ( self . into_bounds ( ) )
604
614
}
Original file line number Diff line number Diff line change @@ -558,12 +558,14 @@ impl KvClient {
558
558
. unwrap ( ) ;
559
559
end_key
560
560
. map ( |k| {
561
- // Scan in TiKV has a weird particularity to it.
562
- // The **start** of a scan is inclusive, unless appended with an '\0', then it is exclusive.
563
- // The **end** of a scan is exclusive, unless appended with an '\0', then it is inclusive.
561
+ // Scan in TiKV has a particularity to it.
564
562
//
565
- // We work around this behavior in this client by making all our scans (Inclusive, Inclusive),
566
- // if we have exclusive bounds our own bounds calculation adjusts it.
563
+ // The **start** of a scan is inclusive, unless appended with an '\0', then it is
564
+ // exclusive. The **end** of a scan is exclusive, unless appended with an '\0',
565
+ // then it is inclusive.
566
+ //
567
+ // Because of `KeyRange::into_keys()` we *know* the keys we have are inclusive
568
+ // (KeyRange calculates it).
567
569
let mut end_key = k. into_inner ( ) ;
568
570
end_key. append ( & mut vec ! [ 0 ] ) ;
569
571
req. set_end_key ( end_key) ;
You can’t perform that action at this time.
0 commit comments