storage: support reverse raw_scan and raw_batch_scan#3724
storage: support reverse raw_scan and raw_batch_scan#3724MyonKeminta merged 27 commits intotikv:masterfrom
Conversation
|
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
|
Great job! |
|
thanks! |
Signed-off-by: kamijin_fanta <kamijin@live.jp>
- for support reverse option pingcap/kvproto#304 Signed-off-by: kamijin_fanta <kamijin@live.jp>
- add reverse request test cases - support reverse in check_key_range - for support reverse option pingcap/kvproto#304 Signed-off-by: kamijin_fanta <kamijin@live.jp>
|
Yes! And, please also fix the error messages from CircleCI |
Signed-off-by: kamijin_fanta <kamijin@live.jp>
|
In fact, I think it's better if the range to scan is always [start_key, end_key) whenever we are scanning forward or backward, which is more close to our semantics of the term "start_key" and "end_key". |
Signed-off-by: kamijin_fanta <kamijin@live.jp>
Signed-off-by: kamijin_fanta <kamijin@live.jp>
|
lowerBound / upperBound and startKey / endKey are distinguished in the code. |
|
Actually currently our semantic is that there is a range [lower_bound, upper_bound). when we do forward scan, we scan from lower_bound to upper_bound in the range. When we do reverse scan, we scan from upper_bound to lower_bound in the range. Maybe we can rename start_key to lower_bound and end_key to upper_bound to be less ambiguous? |
|
@breeswish Seems it's not easy, since you may need to change the fields' name in kvproto |
|
@breeswish oh, sorry, it seems renaming fields in kvproto won't break compatibility between tikv and rpc client..? |
|
At least I think the fields of In coprocessor.proto: // [start, end)
message KeyRange {
bytes start = 1;
bytes end = 2;
}In kvrpcpb.proto message KeyRange {
bytes start_key = 1;
bytes end_key = 2;
}If we change them, we may introduce too much changes to TiKV and TiDB. |
|
the consistency between startKey of ScanRequest and startKey of inside is lost. message ScanRequest {
Context context = 1;
bytes start_key = 2;
uint32 limit = 3;
uint64 version = 4;
bool key_only = 5;
bool reverse = 6;
}I think it is easy to understand clearly distinguish between startKey and lowerBound. |
|
OK. Let's accept this. But please add some comments to explain why |
- check_key_ranges - no specify end_key in reverse batch scan request Signed-off-by: kamijin_fanta <kamijin@live.jp>
- invert reverse option in raw_scan, reverse_raw_scan Signed-off-by: kamijin_fanta <kamijin@live.jp>
|
For the following two ranges, it looks wired in the reverse mode.. The first one is a, b, c and the second one is c, b, a. I prefer to keep the same global total order for all possible ranges in reverse mode, i.e. for every range (a_i, b_i) at index i, we have a_i > a_i+1. let ranges = make_ranges(vec![
(b"a3".to_vec(), b"a".to_vec()),
(b"b3".to_vec(), b"b".to_vec()),
(b"c3".to_vec(), b"c".to_vec()),
]); let ranges = make_ranges(vec![
(b"c3".to_vec(), vec![]),
(b"b3".to_vec(), vec![]),
(b"a3".to_vec(), vec![]),
]); |
|
How do you think @MyonKeminta |
|
@breeswish IMO, I think both are ok.. |
|
PTAL @breeswish |
|
Is it possible to specify ranges in reverse mode like below? let ranges = make_ranges(vec![
(b"c3".to_vec(), b"c".to_vec()),
(b"b3".to_vec(), b"b".to_vec()),
(b"a3".to_vec(), b"a".to_vec()),
]); |
|
@breeswish yes |
|
what is the status of this PR? |
|
Oh, sorry |
|
/run-integration-common-test |
1 similar comment
|
/run-integration-common-test |
|
Thank you for the merge! 🎉 |
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
What have you changed? (mandatory)
What are the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
yes. I added unit test for raw_batch_scan.
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
no.
Does this PR affect tidb-ansible update? (mandatory)
no.
Refer to a related PR or issue link (optional)
Benchmark result if necessary (optional)
Add a few positive/negative examples (optional)