diff --git a/Cargo.toml b/Cargo.toml index a8d03593..8444e830 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["codegen", "examples", "performance_measurement", "performance_measur [package] name = "worktable" -version = "0.6.3" +version = "0.6.4" edition = "2024" authors = ["Handy-caT"] license = "MIT" @@ -25,9 +25,9 @@ lockfree = { version = "0.5.1" } worktable_codegen = { path = "codegen", version = "0.6.0" } futures = "0.3.30" uuid = { version = "1.10.0", features = ["v4", "v7"] } -data_bucket = "0.2.5" +data_bucket = "0.2.6" # data_bucket = { git = "https://github.com/pathscale/DataBucket", branch = "main" } -# data_bucket = { path = "../DataBucket", version = "0.2.4" } +# data_bucket = { path = "../DataBucket", version = "0.2.6" } performance_measurement_codegen = { path = "performance_measurement/codegen", version = "0.1.0", optional = true } performance_measurement = { path = "performance_measurement", version = "0.1.0", optional = true } indexset = { version = "0.12.2", features = ["concurrent", "cdc", "multimap"] } diff --git a/tests/persistence/sync/mod.rs b/tests/persistence/sync/mod.rs index f7bfb31c..49ae2bae 100644 --- a/tests/persistence/sync/mod.rs +++ b/tests/persistence/sync/mod.rs @@ -7,6 +7,7 @@ use worktable::worktable; mod string_primary_index; mod string_re_read; mod string_secondary_index; +mod uuid_; worktable! ( name: TestSync, @@ -35,7 +36,7 @@ worktable! ( #[test] fn test_wait_for_ops_for_empty() { - let config = PersistenceConfig::new("tests/data/sync/insert", "tests/data/sync/insert"); + let config = PersistenceConfig::new("tests/data/sync/wait", "tests/data/sync/wait"); let runtime = tokio::runtime::Builder::new_multi_thread() .worker_threads(2) @@ -45,6 +46,8 @@ fn test_wait_for_ops_for_empty() { .unwrap(); runtime.block_on(async { + remove_dir_if_exists("tests/data/sync/wait".to_string()).await; + let table = TestSyncWorkTable::load_from_file(config.clone()) .await .unwrap(); diff --git a/tests/persistence/sync/uuid_.rs b/tests/persistence/sync/uuid_.rs new file mode 100644 index 00000000..a10274cd --- /dev/null +++ b/tests/persistence/sync/uuid_.rs @@ -0,0 +1,131 @@ +use crate::remove_dir_if_exists; +use uuid::Uuid; + +use worktable::prelude::*; +use worktable_codegen::worktable; + +worktable!( + name: UuidReRead, + persist: true, + columns: { + id: u64 primary_key autoincrement, + first: Uuid, + second: Uuid, + }, + indexes: { + first_idx: first, + second_idx: second unique, + }, +); + +#[test] +fn test_uuid() { + let config = PersistenceConfig::new("tests/data/uuid/reread", "tests/data/uuid/reread"); + + let runtime = tokio::runtime::Builder::new_multi_thread() + .worker_threads(2) + .enable_io() + .enable_time() + .build() + .unwrap(); + + runtime.block_on(async { + remove_dir_if_exists("tests/data/uuid/reread".to_string()).await; + + { + let table = UuidReReadWorkTable::load_from_file(config.clone()) + .await + .unwrap(); + table + .insert(UuidReReadRow { + first: Uuid::now_v7(), + id: table.get_next_pk().into(), + second: Uuid::now_v7(), + }) + .unwrap(); + table + .insert(UuidReReadRow { + first: Uuid::now_v7(), + id: table.get_next_pk().into(), + second: Uuid::now_v7(), + }) + .unwrap(); + + table.wait_for_ops().await + } + { + let table = UuidReReadWorkTable::load_from_file(config.clone()) + .await + .unwrap(); + table + .insert(UuidReReadRow { + first: Uuid::now_v7(), + id: table.get_next_pk().into(), + second: Uuid::now_v7(), + }) + .unwrap(); + table.wait_for_ops().await + } + { + let table = UuidReReadWorkTable::load_from_file(config.clone()) + .await + .unwrap(); + assert_eq!(table.select_all().execute().unwrap().len(), 3); + } + }) +} + +#[test] +fn test_big_amount_reread() { + let config = PersistenceConfig::new("tests/data/uuid/big_amount", "tests/data/uuid/big_amount"); + + let runtime = tokio::runtime::Builder::new_multi_thread() + .worker_threads(2) + .enable_io() + .enable_time() + .build() + .unwrap(); + + runtime.block_on(async { + remove_dir_if_exists("tests/data/uuid/big_amount".to_string()).await; + + { + let table = UuidReReadWorkTable::load_from_file(config.clone()) + .await + .unwrap(); + for _ in 0..1000 { + table + .insert(UuidReReadRow { + first: Uuid::now_v7(), + id: table.get_next_pk().into(), + second: Uuid::now_v7(), + }) + .unwrap(); + } + + table.wait_for_ops().await + } + let second_last = Uuid::now_v7(); + { + let table = UuidReReadWorkTable::load_from_file(config.clone()) + .await + .unwrap(); + + table + .insert(UuidReReadRow { + first: Uuid::now_v7(), + id: table.get_next_pk().into(), + second: second_last, + }) + .unwrap(); + table.wait_for_ops().await + } + { + let table = UuidReReadWorkTable::load_from_file(config.clone()) + .await + .unwrap(); + assert_eq!(table.select_all().execute().unwrap().len(), 1001); + assert!(table.select_by_second(second_last).is_some()); + } + }) +}