Skip to content

The initial version of Raw KV implementation#14

Merged
Hoverbear merged 17 commits intomasterfrom
sun/raw_kv_initial_version
Jan 13, 2019
Merged

The initial version of Raw KV implementation#14
Hoverbear merged 17 commits intomasterfrom
sun/raw_kv_initial_version

Conversation

@sunxiaoguang
Copy link
Copy Markdown
Member

No description provided.

@sunxiaoguang sunxiaoguang changed the title The initial version of Raw KV impleme The initial version of Raw KV implementation Dec 31, 2018
@sunxiaoguang sunxiaoguang force-pushed the sun/raw_kv_initial_version branch from e4b2df0 to 1fc98b0 Compare December 31, 2018 14:15
Comment thread src/lib.rs Outdated
Comment thread src/raw.rs Outdated
Comment thread src/raw.rs Outdated
Comment thread src/rpc/client.rs Outdated
Comment thread src/rpc/context.rs
Comment thread src/rpc/pd/client.rs Outdated
Comment thread src/rpc/pd/client.rs
Comment thread src/rpc/pd/leader.rs Outdated
Comment thread src/rpc/pd/leader.rs
Comment thread src/rpc/pd/leader.rs Outdated
Comment thread src/rpc/pd/leader.rs Outdated
Comment thread src/rpc/pd/leader.rs Outdated
Comment thread src/rpc/util.rs Outdated
Copy link
Copy Markdown
Contributor

@Hoverbear Hoverbear left a comment

Choose a reason for hiding this comment

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

With the understanding this is an initial version and some things will be refined as we move foward, this looks really good. :) A few small nits.

@Hoverbear
Copy link
Copy Markdown
Contributor

Fixes #12

@sunxiaoguang
Copy link
Copy Markdown
Member Author

The tests requires a TiKV cluster running and PD can be connected to with endpoint 127.0.0.1:2379. I'm trying to add a mock TiKV server to make integration test easier, but I guess that will take quite some time.
@Hoverbear @brson

@sunxiaoguang sunxiaoguang force-pushed the sun/raw_kv_initial_version branch from ee46eda to 836cc62 Compare January 1, 2019 10:31
Copy link
Copy Markdown
Contributor

@brson brson left a comment

Choose a reason for hiding this comment

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

@sunxiaoguang this is a huge amount of high quality work. Thanks for being so careful with the design and documentation.

I've reviewed through the rpc client so far, and will continue another day.

I left a number of comments about things that might be changed (a lot of them are hidden behind an expando on this page). The most important I think is the question about wraparound in the conversion from bounds to ranges: https://github.com/tikv/client-rust/pull/14/files#r245455268

Awesome stuff.

Comment thread examples/raw.rs Outdated
Comment thread examples/raw.rs
Comment thread rust-toolchain
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/raw.rs Outdated
/// let req = connected_client.scan(inclusive_range, 2);
/// let result: Vec<KvPair> = req.wait().unwrap();
/// ```
pub fn scan(&self, range: impl KeyRange, limit: impl Into<Option<u32>>) -> Scan {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the impl Into argument really required here? The more clever generics in a type signature the harder to understand.

Is this a clever trick to allow passing either a u32 or None? If so, my instinct is to dislike it (sorry :)) - I lean toward being explicit over clever type-level ergonomics hacks. I'm curious if this pattern is well-represented in the modern Rust ecosystem.

Copy link
Copy Markdown
Member Author

@sunxiaoguang sunxiaoguang Jan 5, 2019

Choose a reason for hiding this comment

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

This is the same interface in Golang client which always take a limit.

func (c *RawKVClient) Scan(startKey []byte, limit int) (keys [][]byte, values [][]byte, err error) 

We can do the same thing here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

BTW: The max limit can be changed in Golang client as MaxRawKVScanLimit is a public variable. I'm not sure if we want to let user change this via Config or simply do not allow user to change it. I'm using a const right now and would like to hear comments from everybody about this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not even sure what this limit is, but I suspect I prefer giving users the option to not think about it, so either Option or Into. I don't have strong feelings about which one.

I think I don't know the domain well enough yet to have an opinion on exactly where it should be possible to set this value.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since the underlying RPC protocol requires limit to be set, and there should be a rational upper bound. I suggest changing this argument to required. @Hoverbear @siddontang What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sunxiaoguang I think that's fine. Let's make sure to expose a 'max'/easy const as tikv_client::NO_SCAN_LIMIT or something so users can find it easily.

Comment thread src/raw.rs Outdated
Comment thread src/raw.rs
Comment thread src/raw.rs Outdated
Comment thread src/raw.rs

fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let config = &self.config;
let rpc = Arc::new(RpcClient::connect(config)?);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is RpcClient::connect synchronous? From reading rpc::client it's not obviously asynchronous.

Copy link
Copy Markdown
Member Author

@sunxiaoguang sunxiaoguang Jan 5, 2019

Choose a reason for hiding this comment

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

It is synchronous at this time. I thought it might be good to leave possibility to support asynchronous connect later on. That way people can implement proxy like applications that support connecting multiple TiKV cluster on the fly without blocking the core. Since it is probably something that's unlikely to happen in real life, if changing connect to blocking style is easier to understand and use, let's change it.

BTW: Thank you so much for all the suggestions, let me take a look and fix them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's fine for now, but istm that ideally everything running on an async event loop should be non-blocking. It's probably worth noting in the doc comments that this future is not asynchronous.

Copy link
Copy Markdown
Member Author

@sunxiaoguang sunxiaoguang left a comment

Choose a reason for hiding this comment

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

@brson @Hoverbear I pushed another commit and try to fix the issues mentioned here. Please take a look, thanks.

@brson
Copy link
Copy Markdown
Contributor

brson commented Jan 8, 2019

I may not get back to finishing my readthrough of this PR for a few days. For the sake of progress, since this is experimental code, I'm comfortable saying LGTM and moving forward. Otherwise I'll get back to it in a bit.

Comment thread src/lib.rs
Comment thread src/lib.rs
Comment thread src/lib.rs
Comment thread examples/raw.rs Outdated
@sunxiaoguang sunxiaoguang force-pushed the sun/raw_kv_initial_version branch from 1ca8e14 to d4f6bcd Compare January 11, 2019 00:14
sunxiaoguang and others added 9 commits January 11, 2019 11:32
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Signed-off-by: Ana Hobden <operator@hoverbear.org>
Signed-off-by: Ana Hobden <operator@hoverbear.org>
Signed-off-by: Ana Hobden <operator@hoverbear.org>
Signed-off-by: Ana Hobden <operator@hoverbear.org>
@Hoverbear Hoverbear force-pushed the sun/raw_kv_initial_version branch from 4a81476 to a7f762a Compare January 11, 2019 19:33
@Hoverbear
Copy link
Copy Markdown
Contributor

Going to try to get some green CI builds.

Signed-off-by: Ana Hobden <operator@hoverbear.org>
@Hoverbear Hoverbear force-pushed the sun/raw_kv_initial_version branch from cc2598a to 19fec55 Compare January 11, 2019 20:39
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Copy link
Copy Markdown
Contributor

@Hoverbear Hoverbear left a comment

Choose a reason for hiding this comment

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

LGTM, still.

@sunxiaoguang
Copy link
Copy Markdown
Member Author

LGTM, still.

@siddontang shell we merge it and leave the rest for future PRs?

Comment thread examples/raw.rs
// This is *advanced usage* and should have some special considerations.
client
.delete(key.clone())
.cf(CUSTOM_CF)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO, I suggest removing cf here because now we can't let the user create CF dynamically. Providing cf here may confuse the users if they want to use other cf.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How about we change cf to private and remove it from example at this time?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sunxiaoguang Maybe you can just remove it from the example for now? If people configure TiKV with custom CFs we must allow them to use them, but perhaps this part of the API can change later.

@Hoverbear
Copy link
Copy Markdown
Contributor

Merging. CI is red due to the service brownout, but we're now seeing multiple PRs built off this one and that's not a good situation. @sunxiaoguang Can you please reflect @siddontang 's minor nit in another PR?

@Hoverbear Hoverbear merged commit ba86754 into master Jan 13, 2019
@sunxiaoguang
Copy link
Copy Markdown
Member Author

Merging. CI is red due to the service brownout, but we're now seeing multiple PRs built off this one and that's not a good situation. @sunxiaoguang Can you please reflect @siddontang 's minor nit in another PR?

Sure, just did it. PTAL #21

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 sticnarf deleted the sun/raw_kv_initial_version branch April 7, 2020 03:56
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.

4 participants