fix RowKVClient scan method can't rightly break loop (#43)

* fix RowKVClient scan method can't rightly break loop

Signed-off-by: Yushen Lin <ldnvnbl@gmail.com>

* fix rawkv Scan and ReverseScan

Signed-off-by: Yushen Lin <ldnvnbl@gmail.com>
This commit is contained in:
LinYushen 2020-01-10 18:13:06 +08:00 committed by Shafreeck Sea
parent ddd42ffad4
commit a3ebdb020c
2 changed files with 3 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
vendor
go.sum
.idea

View File

@ -263,7 +263,7 @@ func (c *Client) Scan(ctx context.Context, startKey, endKey []byte, limit int) (
return nil, nil, errors.WithStack(ErrMaxScanLimitExceeded)
}
for len(keys) < limit {
for len(keys) < limit && (len(endKey) == 0 || bytes.Compare(startKey, endKey) < 0) {
req := &rpc.Request{
Type: rpc.CmdRawScan,
RawScan: &kvrpcpb.RawScanRequest{
@ -307,7 +307,7 @@ func (c *Client) ReverseScan(ctx context.Context, startKey, endKey []byte, limit
return nil, nil, errors.WithStack(ErrMaxScanLimitExceeded)
}
for len(keys) < limit {
for len(keys) < limit && bytes.Compare(startKey, endKey) > 0 {
req := &rpc.Request{
Type: rpc.CmdRawScan,
RawScan: &kvrpcpb.RawScanRequest{