Skip to content
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

Merged
merged 21 commits into from
Jul 6, 2018

Conversation

hicqu
Copy link
Contributor

@hicqu hicqu commented Jun 29, 2018

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:

$ target/debug/tikv-ctl --host localhost:12347 region-properties -r 4
num_files: 1
num_entries: 3348
num_deletes: 2225
mvcc.min_ts: 401128769676902406
mvcc.max_ts: 401144011554816001
mvcc.num_rows: 1079
mvcc.num_puts: 1103
mvcc.num_versions: 1123
mvcc.max_row_versions: 21
middle_key: zmBootstr\377a\377pKey\000\000\377\000\000\373\000\000\000\000\000\377\000\000s\000\000\000\000\000\372\372n\347\2020\037\377\372

@hicqu hicqu added the S: DNM label Jun 29, 2018
);
}

if keys.is_empty() {
Copy link
Member

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.

Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest LGTM

@hicqu
Copy link
Contributor Author

hicqu commented Jul 3, 2018

ping @huachaohuang PTAL.

huachaohuang
huachaohuang previously approved these changes Jul 4, 2018
Copy link
Contributor

@huachaohuang huachaohuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -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".
Copy link
Contributor

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())))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why both are excluded?

Copy link
Contributor Author

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.

@zhangjinpeng87
Copy link
Member

LGTM

@@ -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(
Copy link
Member

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?

if keys.is_empty() {
return Ok(None);
}
let middle = (keys.len() - 1) / 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why sub 1?

Copy link
Member

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

Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndreMouche AndreMouche merged commit 6d8c765 into tikv:master Jul 6, 2018
@hicqu hicqu deleted the region-properties-middle-key branch July 6, 2018 06:15
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants