Skip to content

Commit

Permalink
Implement ScyllaDb as a KeyValueStoreClient (#887)
Browse files Browse the repository at this point in the history
* Implement the basic functionality of the ScyllaDb database as a KeyValueStoreClient.
  • Loading branch information
MathieuDutSik authored Aug 4, 2023
1 parent b8618e1 commit a577933
Show file tree
Hide file tree
Showing 7 changed files with 537 additions and 13 deletions.
198 changes: 192 additions & 6 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ aws-sdk-dynamodb = "0.14.0"
aws-sdk-s3 = "0.14.0"
aws-smithy-http = "0.44.0"
aws-types = "0.14.0"
scylla = "0.8.1"
axum = "0.6.2"
bcs = "0.1.3"
bincode = "1.3.3"
Expand Down
4 changes: 3 additions & 1 deletion linera-views/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ license = "Apache-2.0"
edition = "2021"

[package.metadata.docs.rs]
features = ["rocksdb", "aws", "test"]
features = ["scylladb", "rocksdb", "aws", "test"]
targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]

[features]
test = ["anyhow", "tokio/macros", "tokio/parking_lot"]
aws = ["aws-config", "aws-sdk-dynamodb", "aws-sdk-s3", "aws-smithy-http", "aws-types"]
scylladb = ["scylla"]
db_timings = []
metrics = ["dep:hex", "dep:metrics"]

Expand All @@ -43,6 +44,7 @@ anyhow = { workspace = true, optional = true }
tracing = { workspace = true }
http = { workspace = true }
rand = { workspace = true }
scylla = { workspace = true, optional = true }
rocksdb = { workspace = true, optional = true }
aws-config = { workspace = true, optional = true }
aws-sdk-dynamodb = { workspace = true, optional = true }
Expand Down
16 changes: 13 additions & 3 deletions linera-views/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,27 @@ pub const MIN_VIEW_TAG: u8 = 1;
/// is possible with the way the comparison operators for vectors are built.
///
/// The statement is that p is a prefix of v if and only if p <= v < upper_bound(p).
pub(crate) fn get_upper_bound(key_prefix: &[u8]) -> Bound<Vec<u8>> {
pub(crate) fn get_upper_bound_option(key_prefix: &[u8]) -> Option<Vec<u8>> {
let len = key_prefix.len();
for i in (0..len).rev() {
let val = key_prefix[i];
if val < u8::MAX {
let mut upper_bound = key_prefix[0..i + 1].to_vec();
upper_bound[i] += 1;
return Excluded(upper_bound);
return Some(upper_bound);
}
}
Unbounded
None
}

/// The upper bound that can be used in ranges when accessing
/// a container. That is a vector v is a prefix of p if and only if
/// v belongs to the interval (Included(p), get_upper_bound(p)).
pub(crate) fn get_upper_bound(key_prefix: &[u8]) -> Bound<Vec<u8>> {
match get_upper_bound_option(key_prefix) {
None => Unbounded,
Some(upper_bound) => Excluded(upper_bound),
}
}

/// Computes an interval so that a vector has `key_prefix` as a prefix
Expand Down
Loading

0 comments on commit a577933

Please sign in to comment.