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

Add raw batch put/get/delete/scan #244

Merged
merged 4 commits into from
Apr 2, 2018
Merged

Conversation

sunxiaoguang
Copy link
Contributor

Add batch operations to raw kv, which can significantly reduce gRPC cpu utilization for bulk put and reduce number of roundtrips for reads.

@CLAassistant
Copy link

CLAassistant commented Mar 22, 2018

CLA assistant check
All committers have signed the CLA.

}

message RawScanResponse {
errorpb.Error region_error = 1;
repeated KvPair kvs = 2;
}

message RawBatchScanRequest {
Context context = 1;
repeated bytes start_keys = 2;
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

@sunxiaoguang sunxiaoguang Mar 22, 2018

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@sunxiaoguang sunxiaoguang force-pushed the raw_batch branch 3 times, most recently from 05f2210 to ea82cbf Compare March 24, 2018 06:41
@zhangjinpeng87
Copy link
Contributor

LGTM

@zhangjinpeng87 zhangjinpeng87 changed the title Add raw batch put/get/delete/scan [DNM]Add raw batch put/get/delete/scan Mar 26, 2018
}

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

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.

Copy link
Contributor Author

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.

@siddontang
Copy link
Member

LGTM

1 similar comment
@zhangjinpeng87
Copy link
Contributor

LGTM

@zhangjinpeng87 zhangjinpeng87 changed the title [DNM]Add raw batch put/get/delete/scan Add raw batch put/get/delete/scan Mar 28, 2018
@breezewish breezewish merged commit 1c5dddd into pingcap:master Apr 2, 2018
sunxiaoguang added a commit to tikv/tikv that referenced this pull request Mar 19, 2019
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.
sunxiaoguang added a commit to tikv/tikv that referenced this pull request Mar 19, 2019
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>
sunxiaoguang added a commit to tikv/tikv that referenced this pull request Mar 20, 2019
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>
siddontang pushed a commit to tikv/tikv that referenced this pull request Mar 26, 2019
* 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>
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
* 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>
sticnarf pushed a commit to sticnarf/kvproto 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.

6 participants