Skip to content

Commit

Permalink
feat(cubestore): Introduce support for cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Nov 24, 2022
1 parent 09ceffb commit 72702ff
Show file tree
Hide file tree
Showing 24 changed files with 2,155 additions and 301 deletions.
106 changes: 65 additions & 41 deletions rust/cubestore/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/cubestore/cubestore-sql-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tempfile = "3.2.0"
tar = "0.4.38"

[dev-dependencies]
criterion = { version = "0.3.5", features = ["async_tokio"] }
criterion = { version = "0.4.0", features = ["async_tokio", "html_reports"] }
rocksdb = { version = "0.16.0", default-features = false, features = ["bzip2"] }

[[bench]]
Expand Down
37 changes: 37 additions & 0 deletions rust/cubestore/cubestore-sql-tests/src/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub fn cubestore_benches() -> Vec<Arc<dyn Bench>> {
return vec![
Arc::new(SimpleBench {}),
Arc::new(ParquetMetadataCacheBench {}),
Arc::new(CacheSetGetBench {}),
];
}

Expand Down Expand Up @@ -144,6 +145,42 @@ impl Bench for ParquetMetadataCacheBench {
}
}

pub struct CacheSetGetBench;
#[async_trait]
impl Bench for CacheSetGetBench {
fn config(self: &Self, prefix: &str) -> (String, Config) {
let name = config_name(prefix, "cache_set_get");
let config = Config::test(name.as_str()).update_config(|c| c);
(name, config)
}

async fn setup(self: &Self, services: &CubeServices) -> Result<Arc<BenchState>, CubeError> {
services
.sql_service
.exec_query("CACHE SET TTL 600 'my_key' 'my_value'")
.await?;

let state = Arc::new(());
Ok(state)
}

async fn bench(
self: &Self,
services: &CubeServices,
_state: Arc<BenchState>,
) -> Result<(), CubeError> {
let r = services
.sql_service
.exec_query("CACHE GET 'my_key'")
.await?;

let rows = to_rows(&r);
assert_eq!(rows, vec![vec![TableValue::String("my_value".to_string())]]);

Ok(())
}
}

async fn download_and_unzip(url: &str, dataset: &str) -> Result<Box<Path>, CubeError> {
let root = std::env::current_dir()?.join("data");
let dataset_path = root.join(dataset);
Expand Down
Loading

0 comments on commit 72702ff

Please sign in to comment.