-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Region properties middle key #3260
Conversation
get_region_properties.
get_region_properties.
…into region-properties-middle-key
…into region-properties-middle-key
src/raftstore/store/util.rs
Outdated
); | ||
} | ||
|
||
if keys.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should sort these keys here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
ping @huachaohuang PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/raftstore/store/util.rs
Outdated
@@ -326,6 +327,37 @@ pub fn get_region_approximate_size_cf( | |||
Ok(size) | |||
} | |||
|
|||
/// Get the approxmiate middle key of the region. The returned key maybe | |||
/// is timpstamped if transaction KV is used, and must start with "z". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/timpstamped/timestamped
keys.extend( | ||
props | ||
.index_handles | ||
.range::<[u8], _>((Excluded(start.as_slice()), Excluded(end.as_slice()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why both are excluded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The middle key is supposed to be used for split regions. So we don't hope the key equals to region's start key or end key.
LGTM |
src/raftstore/store/util.rs
Outdated
@@ -326,6 +327,37 @@ pub fn get_region_approximate_size_cf( | |||
Ok(size) | |||
} | |||
|
|||
/// Get the approxmiate middle key of the region. The returned key maybe | |||
/// is timestamped if transaction KV is used, and must start with "z". | |||
pub fn get_region_approximate_middle_cf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we point out what does middle
means?
src/raftstore/store/util.rs
Outdated
if keys.is_empty() { | ||
return Ok(None); | ||
} | ||
let middle = (keys.len() - 1) / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why sub 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, but maybe we could add a comment here? @hicqu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What have you changed? (mandatory)
Add 2 middle_key in region properties response so that we can use the key to split region at approximate middle.
What are the type of the changes? (mandatory)
Improvement.
How has this PR been tested? (mandatory)
make dev.
Add a few positive/negative examples (optional)
tikv-ctl output changes to: