From bda2f8c56bd2f7c0f3bc4f4d7a7f23b109d45052 Mon Sep 17 00:00:00 2001 From: Handy-caT <37216852+Handy-caT@users.noreply.github.com> Date: Tue, 1 Apr 2025 18:18:19 +0300 Subject: [PATCH 1/2] update to new data bucket version --- Cargo.toml | 4 ++-- src/lib.rs | 10 ++++----- src/persistence/space/index/mod.rs | 4 +++- .../space/index/table_of_contents.rs | 22 +++++-------------- src/persistence/space/index/util.rs | 2 +- 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 499072a6..92864089 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ 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.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"] } diff --git a/src/lib.rs b/src/lib.rs index 7c427346..22191a9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,11 +36,11 @@ pub mod prelude { TableSecondaryIndex, TableSecondaryIndexCdc, WorkTable, WorkTableError, }; pub use data_bucket::{ - align, get_index_page_size_from_data_length, map_data_pages_to_general, - map_index_pages_to_general, parse_data_page, parse_page, persist_page, seek_to_page_start, - update_at, DataPage, GeneralHeader, GeneralPage, IndexPage, Interval, Link, PageType, - Persistable, PersistableIndex, SizeMeasurable, SizeMeasure, SpaceInfoPage, - TableOfContentsPage, DATA_VERSION, GENERAL_HEADER_SIZE, INNER_PAGE_SIZE, PAGE_SIZE, + align, get_index_page_size_from_data_length, map_data_pages_to_general, parse_data_page, + parse_page, persist_page, seek_to_page_start, update_at, DataPage, GeneralHeader, + GeneralPage, IndexPage, Interval, Link, PageType, Persistable, PersistableIndex, + SizeMeasurable, SizeMeasure, SpaceInfoPage, TableOfContentsPage, DATA_VERSION, + GENERAL_HEADER_SIZE, INNER_PAGE_SIZE, PAGE_SIZE, }; pub use derive_more::{From, Into}; diff --git a/src/persistence/space/index/mod.rs b/src/persistence/space/index/mod.rs index e0b74c34..79d88d52 100644 --- a/src/persistence/space/index/mod.rs +++ b/src/persistence/space/index/mod.rs @@ -33,7 +33,7 @@ pub use table_of_contents::IndexTableOfContents; pub use util::map_index_pages_to_toc_and_general; #[derive(Debug)] -pub struct SpaceIndex { +pub struct SpaceIndex { space_id: SpaceId, table_of_contents: IndexTableOfContents, next_page_id: Arc, @@ -108,6 +108,8 @@ where >, { let size = get_index_page_size_from_data_length::(DATA_LENGTH as usize); + println!("Length {}", DATA_LENGTH); + println!("Size {}", size); let mut page = IndexPage::new(node_id.key.clone(), size); page.current_index = 1; page.current_length = 1; diff --git a/src/persistence/space/index/table_of_contents.rs b/src/persistence/space/index/table_of_contents.rs index 47c50415..43121838 100644 --- a/src/persistence/space/index/table_of_contents.rs +++ b/src/persistence/space/index/table_of_contents.rs @@ -16,7 +16,7 @@ use rkyv::{rancor, Archive, Deserialize, Serialize}; use tokio::fs::File; #[derive(Debug)] -pub struct IndexTableOfContents { +pub struct IndexTableOfContents { current_page: usize, next_page_id: Arc, pub pages: Vec>>, @@ -24,7 +24,7 @@ pub struct IndexTableOfContents { impl IndexTableOfContents where - T: SizeMeasurable, + T: SizeMeasurable + Ord + Eq, { pub fn new(space_id: SpaceId, next_page_id: Arc) -> Self { let page_id = next_page_id.fetch_add(1, Ordering::Relaxed); @@ -40,10 +40,7 @@ where } } - pub fn get(&self, node_id: &T) -> Option - where - T: Ord + Eq, - { + pub fn get(&self, node_id: &T) -> Option { for page in &self.pages { if page.inner.contains(node_id) { return Some( @@ -63,7 +60,7 @@ where pub fn insert(&mut self, node_id: T, page_id: PageId) where - T: Clone + Ord + Eq + SizeMeasurable, + T: Clone + SizeMeasurable, { let next_page_id = self.next_page_id.clone(); @@ -95,7 +92,7 @@ where pub fn remove(&mut self, node_id: &T) where - T: Clone + Ord + Eq + SizeMeasurable, + T: Clone + SizeMeasurable, { let mut removed = false; let mut i = 0; @@ -117,10 +114,7 @@ where self.pages.iter().flat_map(|v| v.inner.iter()) } - pub fn update_key(&mut self, old_key: &T, new_key: T) - where - T: Ord + Eq, - { + pub fn update_key(&mut self, old_key: &T, new_key: T) { let page = self.get_current_page_mut(); page.inner.update_key(old_key, new_key); } @@ -133,8 +127,6 @@ where pub async fn persist(&mut self, file: &mut File) -> eyre::Result<()> where T: Archive - + Ord - + Eq + Clone + SizeMeasurable + for<'a> Serialize< @@ -157,8 +149,6 @@ where ) -> eyre::Result where T: Archive - + Ord - + Eq + Clone + SizeMeasurable + for<'a> Serialize< diff --git a/src/persistence/space/index/util.rs b/src/persistence/space/index/util.rs index 0b07e92c..c5fcf09f 100644 --- a/src/persistence/space/index/util.rs +++ b/src/persistence/space/index/util.rs @@ -10,7 +10,7 @@ pub fn map_index_pages_to_toc_and_general( Vec>>, ) where - T: Clone + Ord + Eq + SizeMeasurable, + T: Clone + Default + Ord + Eq + SizeMeasurable, { let mut general_index_pages = vec![]; let next_page_id = Arc::new(AtomicU32::new(1)); From c181df712cce6fa87307c33f2383aab6626b9188 Mon Sep 17 00:00:00 2001 From: Handy-caT <37216852+Handy-caT@users.noreply.github.com> Date: Tue, 1 Apr 2025 18:19:12 +0300 Subject: [PATCH 2/2] version --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 92864089..499072a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ 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.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"] }