Open JackL9u opened 3 weeks ago
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign rleungx for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Hi @JackL9u. Thanks for your PR.
I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test
on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test
label.
I understand the commands that are listed here.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 75.64%. Comparing base (
b27f021
) to head (59f8fa0
). Report is 4 commits behind head on master.
/ok-to-test
Can you add some description to explain your work? For example:
This is very helpful to review your code
comments updated with explanations.
What problem does this PR solve?
handle a special case in GetRegion function
Issue Number: ref #6711
What is changed and how does it work?
The (item, index) returned by GetWithIndex(key) function has the following meaning: 1) if there exists an interval defined by [startkey, endkey) such that startkey == key, then item will be the interval object, and index will be the index of this interval in sorted order (sorted by startkey) 2) otherwise, item will be nil, and index will be the number of intervals whose startkey < key.
Since the return values have different meanings in different situations, I want to unify them. To do this, I want to make sure item object is the largest interval (sorted by startkey) whose startkey <= key, and index is the number of interval object whose startkey <= key. Line 1794 - 1805 did this.
To find out if a key lies in an interval, we need to 1) get the item, index defined above 2) make sure item is not nil (it will be nil if key is less then the smallest startkey) 3) and startkey <= key <= endkey Line 1807 - 1814 did this.
To find out if a region [k1, k2) does not overlap with any existing intervals, we need to 1) make sure both k1 and k2 do NOT lie in an existing interval, and 2) there are equal number of intervals before them The 2) check is necessary in case we have an existing interval [2, 4), and we are querying [1, 5). Without the 2) check, it would return true. Line 1824 - 1826 did this.
Line 1816 - 1823 is handling a special case
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note