-
Notifications
You must be signed in to change notification settings - Fork 218
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
Add raw batch put/get/delete/scan #244
Conversation
proto/kvrpcpb.proto
Outdated
} | ||
|
||
message RawScanResponse { | ||
errorpb.Error region_error = 1; | ||
repeated KvPair kvs = 2; | ||
} | ||
|
||
message RawBatchScanRequest { | ||
Context context = 1; | ||
repeated bytes start_keys = 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.
It confused me, could you add some comments for this message?
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.
It's for scanning multiple keys with different prefixes at once. start_key_limit is the limit of pairs for each key prefix, and total_limit is the limit of matched pairs for all prefixes. Normally it is the same as (number of prefixes * start_key_limit) but it could be smaller than that if it's necessary
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.
Here is the reason why we wanted these. We are trying to use TiKV as a distributed storage backend and build bigtable data model on top of raw kv interface. And we mapped column family + row key + qualifier + timestamp as raw key. So to query the most recent version of several qualifiers of the same row key, BatchScan can be used in this scenario to scan records at once.
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.
can you add comments to explain start_keys and each_limit here?
They are not understood intuitively.
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.
Sure, let me add one more field all together at last. Since @zhangjinpeng1987 mentioned there could be duplicated results with this, it's better to have optional end keys as well.
05f2210
to
ea82cbf
Compare
LGTM |
proto/kvrpcpb.proto
Outdated
} | ||
|
||
message RawScanResponse { | ||
errorpb.Error region_error = 1; | ||
repeated KvPair kvs = 2; | ||
} | ||
|
||
message RawBatchScanRequest { | ||
Context context = 1; | ||
repeated bytes start_keys = 2; // start keys for each scanning range |
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.
em, if you want to support end keys here, I prefer using repeated KeyRange ranges
.
If you just want to avoid the case that scanning key1 + limit exceeding the next key2, you can sort the start keys in the server at first like [a, b, c,]
, then use [a, b)
as the range for the first scan, [b, c)
for the second, then go on.
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.
End key is not for limiting records past next start key. It actually meant I'd like to stop at this end key even if number of scanned records does not go beyond limit. I prefer defining a KeyRange as well, didn't know it would be appropriate since other messages used two distinct fields. Let me update it.
LGTM |
1 similar comment
LGTM |
My name is Sun Xiaoguang from Zhihu, where I help make a BigTable like system focusd on OLTP that is using TiKV. I've been contributing to TiKV and the library ecosystem for around a year now. I first touched the TiKV codebase since around March 2018. As part of my involvement with the project I've contributed several improvements to the TiKV Project: * [Added raw batch put/get/delete/scan](pingcap/kvproto#244) * [Changed `get_region` and `get_region_info` to use a common implementation](#3521) * [Print help message when starting tikv-ctl without argument](#3531) * [Clean up unused #[allow] directives](#3553) I also am the first and primary author of the [TiKV Rust Client](https://github.com/tikv/client-rust). You can see related PRs for that here: * [TiKV Rust Client RFC](tikv/rfcs#7) * [The initial version of Raw KV Implementation](tikv/client-rust#14) * [Change `raw::Client::get` to return `Option<Value>`](tikv/client-rust#24) * [Remove cf and batch_scan from `example/raw.rs`](tikv/client-rust#21) I also made the first PR to the mock TiKV project: [A basic implementation of mock TiKV API surface](tikv/mock-tikv#1) As part of my involvement, the TiKV team inquired if I was interested in becoming a maintainer for the project. This PR adds me to the list of maintainers. I have read and understand the expectations of maintainers described in the `GOVERNANCE.md` file.
My name is Sun Xiaoguang from Zhihu, where I help make a BigTable like system focusd on OLTP that is using TiKV. I've been contributing to TiKV and the library ecosystem for around a year now. I first touched the TiKV codebase since around March 2018. As part of my involvement with the project I've contributed several improvements to the TiKV Project: * [Added raw batch put/get/delete/scan](pingcap/kvproto#244) * [Changed `get_region` and `get_region_info` to use a common implementation](#3521) * [Print help message when starting tikv-ctl without argument](#3531) * [Clean up unused #[allow] directives](#3553) I also am the first and primary author of the [TiKV Rust Client](https://github.com/tikv/client-rust). You can see related PRs for that here: * [TiKV Rust Client RFC](tikv/rfcs#7) * [The initial version of Raw KV Implementation](tikv/client-rust#14) * [Change `raw::Client::get` to return `Option<Value>`](tikv/client-rust#24) * [Remove cf and batch_scan from `example/raw.rs`](tikv/client-rust#21) I also made the first PR to the mock TiKV project: [A basic implementation of mock TiKV API surface](tikv/mock-tikv#1) As part of my involvement, the TiKV team inquired if I was interested in becoming a maintainer for the project. This PR adds me to the list of maintainers. I have read and understand the expectations of maintainers described in the `GOVERNANCE.md` file. Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
My name is Sun Xiaoguang from Zhihu, where I help make a BigTable like system focusd on OLTP that is using TiKV. I've been contributing to TiKV and the library ecosystem for around a year now. I first touched the TiKV codebase since around March 2018. As part of my involvement with the project I've contributed several improvements to the TiKV Project: * [Added raw batch put/get/delete/scan](pingcap/kvproto#244) * [Changed `get_region` and `get_region_info` to use a common implementation](#3521) * [Print help message when starting tikv-ctl without argument](#3531) * [Clean up unused #[allow] directives](#3553) I also am the first and primary author of the [TiKV Rust Client](https://github.com/tikv/client-rust). You can see related PRs for that here: * [TiKV Rust Client RFC](tikv/rfcs#7) * [The initial version of Raw KV Implementation](tikv/client-rust#14) * [Change `raw::Client::get` to return `Option<Value>`](tikv/client-rust#24) * [Remove cf and batch_scan from `example/raw.rs`](tikv/client-rust#21) I also made the first PR to the mock TiKV project: [A basic implementation of mock TiKV API surface](tikv/mock-tikv#1) As part of my involvement, the TiKV team inquired if I was interested in becoming a maintainer for the project. This PR adds me to the list of maintainers. I have read and understand the expectations of maintainers described in the `GOVERNANCE.md` file. Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
* Title: Add @sunxiaoguang to MAINTAINERS.md My name is Sun Xiaoguang from Zhihu, where I help make a BigTable like system focusd on OLTP that is using TiKV. I've been contributing to TiKV and the library ecosystem for around a year now. I first touched the TiKV codebase since around March 2018. As part of my involvement with the project I've contributed several improvements to the TiKV Project: * [Added raw batch put/get/delete/scan](pingcap/kvproto#244) * [Changed `get_region` and `get_region_info` to use a common implementation](#3521) * [Print help message when starting tikv-ctl without argument](#3531) * [Clean up unused #[allow] directives](#3553) I also am the first and primary author of the [TiKV Rust Client](https://github.com/tikv/client-rust). You can see related PRs for that here: * [TiKV Rust Client RFC](tikv/rfcs#7) * [The initial version of Raw KV Implementation](tikv/client-rust#14) * [Change `raw::Client::get` to return `Option<Value>`](tikv/client-rust#24) * [Remove cf and batch_scan from `example/raw.rs`](tikv/client-rust#21) I also made the first PR to the mock TiKV project: [A basic implementation of mock TiKV API surface](tikv/mock-tikv#1) As part of my involvement, the TiKV team inquired if I was interested in becoming a maintainer for the project. This PR adds me to the list of maintainers. I have read and understand the expectations of maintainers described in the `GOVERNANCE.md` file. Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
* Title: Add @sunxiaoguang to MAINTAINERS.md My name is Sun Xiaoguang from Zhihu, where I help make a BigTable like system focusd on OLTP that is using TiKV. I've been contributing to TiKV and the library ecosystem for around a year now. I first touched the TiKV codebase since around March 2018. As part of my involvement with the project I've contributed several improvements to the TiKV Project: * [Added raw batch put/get/delete/scan](pingcap/kvproto#244) * [Changed `get_region` and `get_region_info` to use a common implementation](tikv#3521) * [Print help message when starting tikv-ctl without argument](tikv#3531) * [Clean up unused #[allow] directives](tikv#3553) I also am the first and primary author of the [TiKV Rust Client](https://github.com/tikv/client-rust). You can see related PRs for that here: * [TiKV Rust Client RFC](tikv/rfcs#7) * [The initial version of Raw KV Implementation](tikv/client-rust#14) * [Change `raw::Client::get` to return `Option<Value>`](tikv/client-rust#24) * [Remove cf and batch_scan from `example/raw.rs`](tikv/client-rust#21) I also made the first PR to the mock TiKV project: [A basic implementation of mock TiKV API surface](tikv/mock-tikv#1) As part of my involvement, the TiKV team inquired if I was interested in becoming a maintainer for the project. This PR adds me to the list of maintainers. I have read and understand the expectations of maintainers described in the `GOVERNANCE.md` file. Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Add batch operations to raw kv, which can significantly reduce gRPC cpu utilization for bulk put and reduce number of roundtrips for reads.