-
Notifications
You must be signed in to change notification settings - Fork 0
Merge async prototype #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rom Node<K> to Link<K>
…or now) iterator and display trait realisation, most tests, implementation of chunkfs Database trait, etc
…s, tests, some other minor changes
…tic latch crabbing
Piletskii-Oleg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
верю что работает
Cargo.toml
Outdated
| rand = "0.8.5" | ||
| tokio = { version = "1.44.2", features = ["full"] } | ||
| env_logger = "0.11.8" | ||
| log = "0.4.27" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше tracing юзать
src/bplus_tree.rs
Outdated
|
|
||
| extern crate chunkfs; | ||
|
|
||
| /// Easily serializable version of BPlusTree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
она не easily, она просто serializable
| } | ||
|
|
||
| impl<K: Clone + Send + Sync> BPlus<K> { | ||
| async fn serialize(&self) -> SerializableBPlus<K> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше написать что этот метод возвращает сериализуемое дерево
|
|
||
| impl<K: Clone + Send + Sync> Node<K> { | ||
| #[async_recursion] | ||
| async fn serialize(&self) -> SerializableNode<K> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну и тут тоже. оно аллоцирует новое дерево по сути и это хотелось бы знать. а вообще насколько это правильный подход, клонировать все дерево, чтобы его сериализовать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я думаю не очень правильный, но лучше я не успеваю сделать, так что пусть пока хотя бы как-то работает
| BPlus::fmt_node(&self.root, 0, f) | ||
| impl<K: Debug + Ord + Clone + Default + Sync + Send> BPlusStorage<K> { | ||
| /// Creates new instance of B+ tree with given runtime, t and path | ||
| /// runtime is tokio runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
разные предложения надо отделять либо точками либо целыми пустыми строками
src/bplus_tree.rs
Outdated
| *file_guard = File::create( | ||
| self.path.join( | ||
| self.file_number | ||
| .load(std::sync::atomic::Ordering::SeqCst) | ||
| .to_string(), | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
разбей на несколько переменных, чтобы не было такой дикой вложенности, по типу
let file_number = ...
let path = ...
*file_guard = ...
src/bplus_tree.rs
Outdated
| if let Some(guard) = latch_guard { | ||
| drop(guard); | ||
| latch_guard = None; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let Some(guard) = latch_guard.take() ?
src/bplus_tree.rs
Outdated
| None | ||
| let mut leaf = leaf_lock.write().await; | ||
| drop(prev_guard); | ||
| if let Node::Leaf(leaf_node) = &mut *leaf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let Node::Leaf(leaf_node) = &mut *leaf else {
unreachable!()
}
src/bplus_tree.rs
Outdated
| } | ||
|
|
||
| impl< | ||
| K: Default + Ord + Clone + Debug + Sized + Serialize + for<'de> Deserialize<'de> + Sync + Send, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавь алиас на этот набор трейтов, как сделано с ChunkHash например
| }) | ||
| .collect(); | ||
|
|
||
| let keys = futures::future::join_all(key_futures).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в токио вроде такая же штука есть, зачем futures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В токио же нету join_all? вручную придется каждый future эвэйтить и в ключи добавлять, так удобнее просто
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а, действительно, ладно
No description provided.