4
4
//! types (i.e., the types from the client crate) and converts these to the types used in the
5
5
//! generated protobuf code, then calls the low-level ctor functions in the requests module.
6
6
7
- use std:: { iter:: Iterator , ops:: Range , sync:: Arc } ;
8
- use std:: marker:: PhantomData ;
7
+ use std:: { iter:: Iterator , marker:: PhantomData , ops:: Range , sync:: Arc } ;
9
8
10
9
use tikv_client_proto:: { kvrpcpb, metapb} ;
11
10
12
- use crate :: { BoundRange , ColumnFamily , Key , KvPair , raw:: requests, Value } ;
13
- use crate :: request:: KvRequest ;
14
- use crate :: request:: request_codec:: RequestCodec ;
11
+ use crate :: {
12
+ raw:: requests,
13
+ request:: { request_codec:: RequestCodec , KvRequest } ,
14
+ BoundRange , ColumnFamily , Key , KvPair , Value ,
15
+ } ;
15
16
16
- pub fn new_raw_get_request < C : RequestCodec > ( key : Key , cf : Option < ColumnFamily > ) -> kvrpcpb:: RawGetRequest {
17
+ pub fn new_raw_get_request < C : RequestCodec > (
18
+ key : Key ,
19
+ cf : Option < ColumnFamily > ,
20
+ ) -> kvrpcpb:: RawGetRequest {
17
21
requests:: new_raw_get_request :: < C > ( key. into ( ) , cf)
18
22
}
19
23
20
- pub fn new_raw_batch_get_request < C : RequestCodec > (
21
- keys : impl Iterator < Item = Key > ,
24
+ pub fn new_raw_batch_get_request < C : RequestCodec > (
25
+ keys : impl Iterator < Item = Key > ,
22
26
cf : Option < ColumnFamily > ,
23
27
) -> kvrpcpb:: RawBatchGetRequest {
24
28
requests:: new_raw_batch_get_request :: < C > ( keys. map ( Into :: into) . collect ( ) , cf)
25
29
}
26
30
27
- pub fn new_raw_put_request < C : RequestCodec > (
31
+ pub fn new_raw_put_request < C : RequestCodec > (
28
32
key : Key ,
29
33
value : Value ,
30
34
cf : Option < ColumnFamily > ,
@@ -33,43 +37,47 @@ pub fn new_raw_put_request<C:RequestCodec>(
33
37
requests:: new_raw_put_request :: < C > ( key. into ( ) , value, cf, atomic)
34
38
}
35
39
36
- pub fn new_raw_batch_put_request < C : RequestCodec > (
37
- pairs : impl Iterator < Item = KvPair > ,
40
+ pub fn new_raw_batch_put_request < C : RequestCodec > (
41
+ pairs : impl Iterator < Item = KvPair > ,
38
42
cf : Option < ColumnFamily > ,
39
43
atomic : bool ,
40
44
) -> kvrpcpb:: RawBatchPutRequest {
41
45
requests:: new_raw_batch_put_request :: < C > ( pairs. map ( Into :: into) . collect ( ) , cf, atomic)
42
46
}
43
47
44
- pub fn new_raw_delete_request < C : RequestCodec > (
48
+ pub fn new_raw_delete_request < C : RequestCodec > (
45
49
key : Key ,
46
50
cf : Option < ColumnFamily > ,
47
51
atomic : bool ,
48
52
) -> kvrpcpb:: RawDeleteRequest {
49
53
requests:: new_raw_delete_request :: < C > ( key. into ( ) , cf, atomic)
50
54
}
51
55
52
- pub fn new_raw_batch_delete_request < C : RequestCodec > (
53
- keys : impl Iterator < Item = Key > ,
56
+ pub fn new_raw_batch_delete_request < C : RequestCodec > (
57
+ keys : impl Iterator < Item = Key > ,
54
58
cf : Option < ColumnFamily > ,
55
59
) -> kvrpcpb:: RawBatchDeleteRequest {
56
60
requests:: new_raw_batch_delete_request :: < C > ( keys. map ( Into :: into) . collect ( ) , cf)
57
61
}
58
62
59
- pub fn new_raw_delete_range_request < C : RequestCodec > (
63
+ pub fn new_raw_delete_range_request < C : RequestCodec > (
60
64
range : BoundRange ,
61
65
cf : Option < ColumnFamily > ,
62
66
) -> kvrpcpb:: RawDeleteRangeRequest {
63
67
let ( start_key, end_key) = range. into_keys ( ) ;
64
- requests:: new_raw_delete_range_request :: < C > ( start_key. into ( ) , end_key. unwrap_or_default ( ) . into ( ) , cf)
68
+ requests:: new_raw_delete_range_request :: < C > (
69
+ start_key. into ( ) ,
70
+ end_key. unwrap_or_default ( ) . into ( ) ,
71
+ cf,
72
+ )
65
73
}
66
74
67
- pub fn new_raw_scan_request < C : RequestCodec > (
75
+ pub fn new_raw_scan_request < C : RequestCodec > (
68
76
range : BoundRange ,
69
77
limit : u32 ,
70
78
key_only : bool ,
71
79
cf : Option < ColumnFamily > ,
72
- ) -> kvrpcpb:: RawScanRequest {
80
+ ) -> kvrpcpb:: RawScanRequest {
73
81
let ( start_key, end_key) = range. into_keys ( ) ;
74
82
requests:: new_raw_scan_request :: < C > (
75
83
start_key. into ( ) ,
@@ -80,16 +88,21 @@ pub fn new_raw_scan_request<C:RequestCodec>(
80
88
)
81
89
}
82
90
83
- pub fn new_raw_batch_scan_request < C : RequestCodec > (
84
- ranges : impl Iterator < Item = BoundRange > ,
91
+ pub fn new_raw_batch_scan_request < C : RequestCodec > (
92
+ ranges : impl Iterator < Item = BoundRange > ,
85
93
each_limit : u32 ,
86
94
key_only : bool ,
87
95
cf : Option < ColumnFamily > ,
88
96
) -> kvrpcpb:: RawBatchScanRequest {
89
- requests:: new_raw_batch_scan_request :: < C > ( ranges. map ( Into :: into) . collect ( ) , each_limit, key_only, cf)
97
+ requests:: new_raw_batch_scan_request :: < C > (
98
+ ranges. map ( Into :: into) . collect ( ) ,
99
+ each_limit,
100
+ key_only,
101
+ cf,
102
+ )
90
103
}
91
104
92
- pub fn new_cas_request < C : RequestCodec > (
105
+ pub fn new_cas_request < C : RequestCodec > (
93
106
key : Key ,
94
107
value : Value ,
95
108
previous_value : Option < Value > ,
@@ -98,10 +111,10 @@ pub fn new_cas_request<C:RequestCodec>(
98
111
requests:: new_cas_request :: < C > ( key. into ( ) , value, previous_value, cf)
99
112
}
100
113
101
- pub fn new_raw_coprocessor_request < C : RequestCodec > (
114
+ pub fn new_raw_coprocessor_request < C : RequestCodec > (
102
115
copr_name : String ,
103
116
copr_version_req : String ,
104
- ranges : impl Iterator < Item = BoundRange > ,
117
+ ranges : impl Iterator < Item = BoundRange > ,
105
118
request_builder : impl Fn ( metapb:: Region , Vec < Range < Key > > ) -> Vec < u8 > + Send + Sync + ' static ,
106
119
) -> requests:: RawCoprocessorRequest {
107
120
requests:: new_raw_coprocessor_request :: < C > (
0 commit comments