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 @@ -25,9 +25,9 @@ lockfree = { version = "0.5.1" }
worktable_codegen = { path = "codegen", version = "0.5.1" }
futures = "0.3.30"
uuid = { version = "1.10.0", features = ["v4"] }
data_bucket = "0.2.1"
# data_bucket = { git = "https://github.com/pathscale/DataBucket", branch = "main" }
# data_bucket = { path = "../DataBucket", version = "0.2.0" }
#data_bucket = "0.2.1"
data_bucket = { git = "https://github.com/pathscale/DataBucket", branch = "main" }
# data_bucket = { path = "../DataBucket", version = "0.2.1" }
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.11.2", features = ["concurrent", "cdc", "multimap"] }
Expand Down
9 changes: 6 additions & 3 deletions src/persistence/space/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::persistence::SpaceDataOps;
use crate::prelude::WT_DATA_EXTENSION;
use convert_case::{Case, Casing};
use data_bucket::{
parse_page, persist_page, update_at, DataPage, GeneralHeader, GeneralPage, Link, PageType,
Persistable, SizeMeasurable, SpaceInfoPage, GENERAL_HEADER_SIZE,
parse_general_header_by_index, parse_page, persist_page, update_at, DataPage, GeneralHeader,
GeneralPage, Link, PageType, Persistable, SizeMeasurable, SpaceInfoPage, GENERAL_HEADER_SIZE,
};
use rkyv::api::high::HighDeserializer;
use rkyv::rancor::Strategy;
Expand Down Expand Up @@ -75,12 +75,14 @@ where
let info = parse_page::<_, DATA_LENGTH>(&mut data_file, 0).await?;
let file_length = data_file.metadata().await?.len();
let page_id = file_length / (DATA_LENGTH as u64 + GENERAL_HEADER_SIZE as u64);
let last_page_header =
parse_general_header_by_index(&mut data_file, page_id as u32).await?;

Ok(Self {
data_file,
info,
last_page_id: page_id as u32,
current_data_length: 0,
current_data_length: last_page_header.data_length,
})
}

Expand Down Expand Up @@ -117,6 +119,7 @@ where
}
self.current_data_length += link.length;
self.update_data_length().await?;
println!("{:?}", self.current_data_length);
update_at::<{ DATA_LENGTH }>(&mut self.data_file, link, bytes).await
}

Expand Down
2 changes: 2 additions & 0 deletions tests/persistence/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::persistence::{AnotherByIdQuery, TestPersistRow, TestPersistWorkTable}
use crate::remove_dir_if_exists;
use worktable::prelude::{PersistenceConfig, PrimaryKeyGeneratorState};

mod string_re_read;

#[test]
fn test_space_insert_sync() {
let config = PersistenceConfig::new("tests/data/sync/insert", "tests/data/sync/insert");
Expand Down
79 changes: 79 additions & 0 deletions tests/persistence/sync/string_re_read.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use crate::remove_dir_if_exists;

use worktable::prelude::*;
use worktable_codegen::worktable;

worktable!(
name: StringReRead,
persist: true,
columns: {
id: u64 primary_key autoincrement,
first: String,
second: String,
third: String,
last: String,
},
);

#[test]
fn test_key() {
let config = PersistenceConfig::new("tests/data/key", "tests/data/key");

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/key".to_string()).await;

{
let table = StringReReadWorkTable::load_from_file(config.clone())
.await
.unwrap();
table
.insert(StringReReadRow {
first: "first".to_string(),
id: table.get_next_pk().into(),
third: "third".to_string(),
second: "second".to_string(),
last: "_________________________last_____________________".to_string(),
})
.unwrap();
table
.insert(StringReReadRow {
first: "first_again".to_string(),
id: table.get_next_pk().into(),
third: "third_again".to_string(),
second: "second_again".to_string(),
last: "_________________________last_____________________".to_string(),
})
.unwrap();

table.wait_for_ops().await
}
{
let table = StringReReadWorkTable::load_from_file(config.clone())
.await
.unwrap();
table
.insert(StringReReadRow {
first: "first_last".to_string(),
id: table.get_next_pk().into(),
third: "third_last".to_string(),
second: "second_last".to_string(),
last: "_________________________last_____________________".to_string(),
})
.unwrap();
table.wait_for_ops().await
}
{
let table = StringReReadWorkTable::load_from_file(config.clone())
.await
.unwrap();
assert_eq!(table.select_all().execute().unwrap().len(), 3);
}
})
}
Loading