@@ -29,19 +29,10 @@ import (
29
29
)
30
30
31
31
var (
32
- // MaxRawKVScanLimit is the maximum scan limit for rawkv Scan.
33
- MaxRawKVScanLimit = 10240
34
32
// ErrMaxScanLimitExceeded is returned when the limit for rawkv Scan is to large.
35
33
ErrMaxScanLimitExceeded = errors .New ("limit should be less than MaxRawKVScanLimit" )
36
34
)
37
35
38
- const (
39
- // rawBatchPutSize is the maximum size limit for rawkv each batch put request.
40
- rawBatchPutSize = 16 * 1024
41
- // rawBatchPairCount is the maximum limit for rawkv each batch get/delete request.
42
- rawBatchPairCount = 512
43
- )
44
-
45
36
// RawKVClient is a client of TiKV server which is used as a key-value storage,
46
37
// only GET/PUT/DELETE commands are supported.
47
38
type RawKVClient struct {
@@ -278,7 +269,7 @@ func (c *RawKVClient) Scan(startKey, endKey []byte, limit int) (keys [][]byte, v
278
269
start := time .Now ()
279
270
defer func () { metrics .RawkvCmdHistogram .WithLabelValues ("raw_scan" ).Observe (time .Since (start ).Seconds ()) }()
280
271
281
- if limit > MaxRawKVScanLimit {
272
+ if limit > config . MaxRawKVScanLimit {
282
273
return nil , nil , errors .WithStack (ErrMaxScanLimitExceeded )
283
274
}
284
275
@@ -319,7 +310,7 @@ func (c *RawKVClient) sendReq(key []byte, req *rpc.Request) (*rpc.Response, *loc
319
310
if err != nil {
320
311
return nil , nil , err
321
312
}
322
- resp , err := sender .SendReq (bo , req , loc .Region , rpc .ReadTimeoutShort )
313
+ resp , err := sender .SendReq (bo , req , loc .Region , config .ReadTimeoutShort )
323
314
if err != nil {
324
315
return nil , nil , err
325
316
}
@@ -346,7 +337,7 @@ func (c *RawKVClient) sendBatchReq(bo *retry.Backoffer, keys [][]byte, cmdType r
346
337
347
338
var batches []batch
348
339
for regionID , groupKeys := range groups {
349
- batches = appendKeyBatches (batches , regionID , groupKeys , rawBatchPairCount )
340
+ batches = appendKeyBatches (batches , regionID , groupKeys , config . RawBatchPairCount )
350
341
}
351
342
bo , cancel := bo .Fork ()
352
343
ches := make (chan singleBatchResp , len (batches ))
@@ -405,7 +396,7 @@ func (c *RawKVClient) doBatchReq(bo *retry.Backoffer, batch batch, cmdType rpc.C
405
396
}
406
397
407
398
sender := rpc .NewRegionRequestSender (c .regionCache , c .rpcClient )
408
- resp , err := sender .SendReq (bo , req , batch .regionID , rpc .ReadTimeoutShort )
399
+ resp , err := sender .SendReq (bo , req , batch .regionID , config .ReadTimeoutShort )
409
400
410
401
batchResp := singleBatchResp {}
411
402
if err != nil {
@@ -473,7 +464,7 @@ func (c *RawKVClient) sendDeleteRangeReq(startKey []byte, endKey []byte) (*rpc.R
473
464
},
474
465
}
475
466
476
- resp , err := sender .SendReq (bo , req , loc .Region , rpc .ReadTimeoutShort )
467
+ resp , err := sender .SendReq (bo , req , loc .Region , config .ReadTimeoutShort )
477
468
if err != nil {
478
469
return nil , nil , err
479
470
}
@@ -504,7 +495,7 @@ func (c *RawKVClient) sendBatchPut(bo *retry.Backoffer, keys, values [][]byte) e
504
495
var batches []batch
505
496
// split the keys by size and RegionVerID
506
497
for regionID , groupKeys := range groups {
507
- batches = appendBatches (batches , regionID , groupKeys , keyToValue , rawBatchPutSize )
498
+ batches = appendBatches (batches , regionID , groupKeys , keyToValue , config . RawBatchPutSize )
508
499
}
509
500
bo , cancel := bo .Fork ()
510
501
ch := make (chan error , len (batches ))
@@ -583,7 +574,7 @@ func (c *RawKVClient) doBatchPut(bo *retry.Backoffer, batch batch) error {
583
574
}
584
575
585
576
sender := rpc .NewRegionRequestSender (c .regionCache , c .rpcClient )
586
- resp , err := sender .SendReq (bo , req , batch .regionID , rpc .ReadTimeoutShort )
577
+ resp , err := sender .SendReq (bo , req , batch .regionID , config .ReadTimeoutShort )
587
578
if err != nil {
588
579
return err
589
580
}
0 commit comments