Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"] }
Expand Down
5 changes: 4 additions & 1 deletion tests/persistence/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use worktable::worktable;
mod string_primary_index;
mod string_re_read;
mod string_secondary_index;
mod uuid_;

worktable! (
name: TestSync,
Expand Down Expand Up @@ -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)
Expand All @@ -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();
Expand Down
131 changes: 131 additions & 0 deletions tests/persistence/sync/uuid_.rs
Original file line number Diff line number Diff line change
@@ -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());
}
})
}
Loading