1
1
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
2
2
3
3
use super :: ColumnFamily ;
4
- use crate :: { rpc:: RpcClient , Error , Key , BoundRange , KvPair , Result , Value } ;
4
+ use crate :: { rpc:: RpcClient , BoundRange , Error , Key , KvPair , Result , Value } ;
5
5
use futures:: prelude:: * ;
6
6
use futures:: task:: { Context , Poll } ;
7
- use std:: { ops :: Bound , pin:: Pin , sync:: Arc , u32} ;
7
+ use std:: { pin:: Pin , sync:: Arc , u32} ;
8
8
9
9
const MAX_RAW_KV_SCAN_LIMIT : u32 = 10240 ;
10
10
@@ -82,9 +82,9 @@ pub struct Get {
82
82
}
83
83
84
84
impl Get {
85
- pub fn new ( client : Arc < RpcClient > , inner : GetInner ) -> Self {
85
+ pub fn new ( client : Arc < RpcClient > , key : Key ) -> Self {
86
86
Self {
87
- state : RequestState :: new ( client, inner ) ,
87
+ state : RequestState :: new ( client, GetInner { key } ) ,
88
88
}
89
89
}
90
90
@@ -103,16 +103,10 @@ impl Future for Get {
103
103
}
104
104
}
105
105
106
- pub struct GetInner {
106
+ struct GetInner {
107
107
key : Key ,
108
108
}
109
109
110
- impl GetInner {
111
- pub fn new ( key : Key ) -> Self {
112
- GetInner { key }
113
- }
114
- }
115
-
116
110
impl RequestInner for GetInner {
117
111
type Resp = Option < Value > ;
118
112
@@ -134,9 +128,9 @@ pub struct BatchGet {
134
128
}
135
129
136
130
impl BatchGet {
137
- pub fn new ( client : Arc < RpcClient > , inner : BatchGetInner ) -> Self {
131
+ pub fn new ( client : Arc < RpcClient > , keys : Vec < Key > ) -> Self {
138
132
Self {
139
- state : RequestState :: new ( client, inner ) ,
133
+ state : RequestState :: new ( client, BatchGetInner { keys } ) ,
140
134
}
141
135
}
142
136
@@ -155,7 +149,7 @@ impl Future for BatchGet {
155
149
}
156
150
}
157
151
158
- pub struct BatchGetInner {
152
+ struct BatchGetInner {
159
153
keys : Vec < Key > ,
160
154
}
161
155
@@ -171,12 +165,6 @@ impl RequestInner for BatchGetInner {
171
165
}
172
166
}
173
167
174
- impl BatchGetInner {
175
- pub fn new ( keys : Vec < Key > ) -> Self {
176
- BatchGetInner { keys }
177
- }
178
- }
179
-
180
168
/// An unresolved [`Client::put`](Client::put) request.
181
169
///
182
170
/// Once resolved this request will result in the putting of the value associated with the given
@@ -186,9 +174,9 @@ pub struct Put {
186
174
}
187
175
188
176
impl Put {
189
- pub fn new ( client : Arc < RpcClient > , inner : PutInner ) -> Self {
177
+ pub fn new ( client : Arc < RpcClient > , key : Key , value : Value ) -> Self {
190
178
Self {
191
- state : RequestState :: new ( client, inner ) ,
179
+ state : RequestState :: new ( client, PutInner { key , value } ) ,
192
180
}
193
181
}
194
182
@@ -207,17 +195,11 @@ impl Future for Put {
207
195
}
208
196
}
209
197
210
- pub struct PutInner {
198
+ struct PutInner {
211
199
key : Key ,
212
200
value : Value ,
213
201
}
214
202
215
- impl PutInner {
216
- pub fn new ( key : Key , value : Value ) -> Self {
217
- PutInner { key, value }
218
- }
219
- }
220
-
221
203
impl RequestInner for PutInner {
222
204
type Resp = ( ) ;
223
205
@@ -235,9 +217,9 @@ pub struct BatchPut {
235
217
}
236
218
237
219
impl BatchPut {
238
- pub fn new ( client : Arc < RpcClient > , inner : BatchPutInner ) -> Self {
220
+ pub fn new ( client : Arc < RpcClient > , pairs : Vec < KvPair > ) -> Self {
239
221
Self {
240
- state : RequestState :: new ( client, inner ) ,
222
+ state : RequestState :: new ( client, BatchPutInner { pairs } ) ,
241
223
}
242
224
}
243
225
@@ -256,16 +238,10 @@ impl Future for BatchPut {
256
238
}
257
239
}
258
240
259
- pub struct BatchPutInner {
241
+ struct BatchPutInner {
260
242
pairs : Vec < KvPair > ,
261
243
}
262
244
263
- impl BatchPutInner {
264
- pub fn new ( pairs : Vec < KvPair > ) -> Self {
265
- BatchPutInner { pairs }
266
- }
267
- }
268
-
269
245
impl RequestInner for BatchPutInner {
270
246
type Resp = ( ) ;
271
247
@@ -282,9 +258,9 @@ pub struct Delete {
282
258
}
283
259
284
260
impl Delete {
285
- pub fn new ( client : Arc < RpcClient > , inner : DeleteInner ) -> Self {
261
+ pub fn new ( client : Arc < RpcClient > , key : Key ) -> Self {
286
262
Self {
287
- state : RequestState :: new ( client, inner ) ,
263
+ state : RequestState :: new ( client, DeleteInner { key } ) ,
288
264
}
289
265
}
290
266
@@ -303,16 +279,10 @@ impl Future for Delete {
303
279
}
304
280
}
305
281
306
- pub struct DeleteInner {
282
+ struct DeleteInner {
307
283
key : Key ,
308
284
}
309
285
310
- impl DeleteInner {
311
- pub fn new ( key : Key ) -> Self {
312
- DeleteInner { key }
313
- }
314
- }
315
-
316
286
impl RequestInner for DeleteInner {
317
287
type Resp = ( ) ;
318
288
@@ -329,9 +299,9 @@ pub struct BatchDelete {
329
299
}
330
300
331
301
impl BatchDelete {
332
- pub fn new ( client : Arc < RpcClient > , inner : BatchDeleteInner ) -> Self {
302
+ pub fn new ( client : Arc < RpcClient > , keys : Vec < Key > ) -> Self {
333
303
Self {
334
- state : RequestState :: new ( client, inner ) ,
304
+ state : RequestState :: new ( client, BatchDeleteInner { keys } ) ,
335
305
}
336
306
}
337
307
@@ -350,16 +320,10 @@ impl Future for BatchDelete {
350
320
}
351
321
}
352
322
353
- pub struct BatchDeleteInner {
323
+ struct BatchDeleteInner {
354
324
keys : Vec < Key > ,
355
325
}
356
326
357
- impl BatchDeleteInner {
358
- pub fn new ( keys : Vec < Key > ) -> Self {
359
- BatchDeleteInner { keys }
360
- }
361
- }
362
-
363
327
impl RequestInner for BatchDeleteInner {
364
328
type Resp = ( ) ;
365
329
@@ -376,9 +340,9 @@ pub struct Scan {
376
340
}
377
341
378
342
impl Scan {
379
- pub fn new ( client : Arc < RpcClient > , inner : ScanInner ) -> Self {
343
+ pub fn new ( client : Arc < RpcClient > , range : BoundRange , limit : u32 ) -> Self {
380
344
Scan {
381
- state : RequestState :: new ( client, inner ) ,
345
+ state : RequestState :: new ( client, ScanInner :: new ( range , limit ) ) ,
382
346
}
383
347
}
384
348
@@ -404,14 +368,14 @@ impl Future for Scan {
404
368
}
405
369
}
406
370
407
- pub struct ScanInner {
371
+ struct ScanInner {
408
372
range : BoundRange ,
409
373
limit : u32 ,
410
374
key_only : bool ,
411
375
}
412
376
413
377
impl ScanInner {
414
- pub fn new ( range : BoundRange , limit : u32 ) -> Self {
378
+ fn new ( range : BoundRange , limit : u32 ) -> Self {
415
379
ScanInner {
416
380
range,
417
381
limit,
@@ -447,9 +411,9 @@ pub struct BatchScan {
447
411
}
448
412
449
413
impl BatchScan {
450
- pub fn new ( client : Arc < RpcClient > , inner : BatchScanInner ) -> Self {
414
+ pub fn new ( client : Arc < RpcClient > , ranges : Vec < BoundRange > , each_limit : u32 ) -> Self {
451
415
BatchScan {
452
- state : RequestState :: new ( client, inner ) ,
416
+ state : RequestState :: new ( client, BatchScanInner :: new ( ranges , each_limit ) ) ,
453
417
}
454
418
}
455
419
@@ -475,14 +439,14 @@ impl Future for BatchScan {
475
439
}
476
440
}
477
441
478
- pub struct BatchScanInner {
442
+ struct BatchScanInner {
479
443
ranges : Vec < BoundRange > ,
480
444
each_limit : u32 ,
481
445
key_only : bool ,
482
446
}
483
447
484
448
impl BatchScanInner {
485
- pub fn new ( ranges : Vec < BoundRange > , each_limit : u32 ) -> Self {
449
+ fn new ( ranges : Vec < BoundRange > , each_limit : u32 ) -> Self {
486
450
BatchScanInner {
487
451
ranges,
488
452
each_limit,
@@ -519,9 +483,9 @@ pub struct DeleteRange {
519
483
}
520
484
521
485
impl DeleteRange {
522
- pub fn new ( client : Arc < RpcClient > , inner : DeleteRangeInner ) -> Self {
486
+ pub fn new ( client : Arc < RpcClient > , range : BoundRange ) -> Self {
523
487
Self {
524
- state : RequestState :: new ( client, inner ) ,
488
+ state : RequestState :: new ( client, DeleteRangeInner { range } ) ,
525
489
}
526
490
}
527
491
@@ -544,12 +508,6 @@ pub struct DeleteRangeInner {
544
508
range : BoundRange ,
545
509
}
546
510
547
- impl DeleteRangeInner {
548
- pub fn new ( range : BoundRange ) -> Self {
549
- DeleteRangeInner { range }
550
- }
551
- }
552
-
553
511
impl RequestInner for DeleteRangeInner {
554
512
type Resp = ( ) ;
555
513
0 commit comments