Skip to content

Commit

Permalink
Merge branch 'master' into sysinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden committed Sep 16, 2022
2 parents f09f01c + c168aba commit e9f8bb8
Show file tree
Hide file tree
Showing 223 changed files with 8,635 additions and 2,507 deletions.
98 changes: 84 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,20 @@ rusoto_mock = { git = "https://github.com/tikv/rusoto", branch = "gh1482-s3-addr
rusoto_s3 = { git = "https://github.com/tikv/rusoto", branch = "gh1482-s3-addr-styles" }
rusoto_sts = { git = "https://github.com/tikv/rusoto", branch = "gh1482-s3-addr-styles" }

snappy-sys = { git = "https://github.com/busyjay/rust-snappy.git", branch = "static-link" }

# remove this when https://github.com/danburkert/fs2-rs/pull/42 is merged.
fs2 = { git = "https://github.com/tabokie/fs2-rs", branch = "tikv" }

# Remove this when a new version is release. We need to solve rust-lang/cmake-rs#143.
cmake = { git = "https://github.com/rust-lang/cmake-rs" }

[target.'cfg(target_os = "linux")'.dependencies]
procinfo = { git = "https://github.com/tikv/procinfo-rs", rev = "6599eb9dca74229b2c1fcc44118bef7eff127128" }
# When you modify TiKV cooperatively with kvproto, this will be useful to submit the PR to TiKV and the PR to
# kvproto at the same time.
# After the PR to kvproto is merged, remember to comment this out and run `cargo update -p kvproto`.
# [patch.'https://github.com/pingcap/kvproto']
[patch.'https://github.com/pingcap/kvproto']
# kvproto = { git = "https://github.com/your_github_id/kvproto", branch="your_branch" }

[workspace]
Expand Down Expand Up @@ -236,6 +241,9 @@ members = [
"components/encryption",
"components/encryption/export",
"components/engine_rocks_helper",
# Only enable tirocks in local development, otherwise it can slow down compilation.
# TODO: always enable tirocks and remove engine_rocks.
# "components/engine_tirocks",
"components/error_code",
"components/external_storage",
"components/external_storage/export",
Expand All @@ -257,6 +265,7 @@ members = [
"components/test_coprocessor",
"components/test_coprocessor_plugin/example_plugin",
"components/test_pd",
"components/test_pd_client",
"components/test_raftstore",
"components/test_sst_importer",
"components/test_storage",
Expand Down Expand Up @@ -292,6 +301,10 @@ opt-level = 1
debug = false
opt-level = 1

[profile.dev.package.tirocks-sys]
debug = false
opt-level = 1

[profile.dev.package.tests]
debug = 1
opt-level = 1
Expand Down
2 changes: 1 addition & 1 deletion cmd/tikv-ctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pd_client = { path = "../../components/pd_client", default-features = false }
prometheus = { version = "0.13", features = ["nightly"] }
protobuf = { version = "2.8", features = ["bytes"] }
raft = { version = "0.7.0", default-features = false, features = ["protobuf-codec"] }
raft-engine-ctl = { git = "https://github.com/tikv/raft-engine.git" }
raft-engine-ctl = "0.3.0"
raft_log_engine = { path = "../../components/raft_log_engine", default-features = false }
raftstore = { path = "../../components/raftstore", default-features = false }
rand = "0.8"
Expand Down
30 changes: 18 additions & 12 deletions components/api_version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,13 @@ pub struct RawValue<T: AsRef<[u8]>> {
impl<T: AsRef<[u8]>> RawValue<T> {
#[inline]
pub fn is_valid(&self, current_ts: u64) -> bool {
!self.is_delete
&& self
.expire_ts
.map_or(true, |expire_ts| expire_ts > current_ts)
!self.is_delete & !self.is_ttl_expired(current_ts)
}

#[inline]
pub fn is_ttl_expired(&self, current_ts: u64) -> bool {
self.expire_ts
.map_or(false, |expire_ts| expire_ts <= current_ts)
}
}

Expand Down Expand Up @@ -487,22 +490,25 @@ mod tests {
#[test]
fn test_value_valid() {
let cases = vec![
// expire_ts, is_delete, expect_is_valid
(None, false, true),
(None, true, false),
(Some(5), false, false),
(Some(5), true, false),
(Some(100), false, true),
(Some(100), true, false),
// expire_ts, is_delete, expect_is_valid, expect_ttl_expired
(None, false, true, false),
(None, true, false, false),
(Some(5), false, false, true),
(Some(5), true, false, true),
(Some(100), false, true, false),
(Some(100), true, false, false),
];

for (idx, (expire_ts, is_delete, expect_is_valid)) in cases.into_iter().enumerate() {
for (idx, (expire_ts, is_delete, expect_is_valid, ttl_expired)) in
cases.into_iter().enumerate()
{
let raw_value = RawValue {
user_value: b"value",
expire_ts,
is_delete,
};
assert_eq!(raw_value.is_valid(10), expect_is_valid, "case {}", idx);
assert_eq!(raw_value.is_ttl_expired(10), ttl_expired, "case {}", idx);
}
}

Expand Down

0 comments on commit e9f8bb8

Please sign in to comment.