Merge async prototype#3
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
| rand = "0.8.5" | ||
| tokio = { version = "1.44.2", features = ["full"] } | ||
| env_logger = "0.11.8" | ||
| log = "0.4.27" |
|
|
||
| extern crate chunkfs; | ||
|
|
||
| /// Easily serializable version of BPlusTree |
There was a problem hiding this comment.
она не easily, она просто serializable
| } | ||
|
|
||
| impl<K: Clone + Send + Sync> BPlus<K> { | ||
| async fn serialize(&self) -> SerializableBPlus<K> { |
There was a problem hiding this comment.
лучше написать что этот метод возвращает сериализуемое дерево
|
|
||
| impl<K: Clone + Send + Sync> Node<K> { | ||
| #[async_recursion] | ||
| async fn serialize(&self) -> SerializableNode<K> { |
There was a problem hiding this comment.
ну и тут тоже. оно аллоцирует новое дерево по сути и это хотелось бы знать. а вообще насколько это правильный подход, клонировать все дерево, чтобы его сериализовать?
There was a problem hiding this comment.
я думаю не очень правильный, но лучше я не успеваю сделать, так что пусть пока хотя бы как-то работает
| 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.
разные предложения надо отделять либо точками либо целыми пустыми строками
| *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.
разбей на несколько переменных, чтобы не было такой дикой вложенности, по типу
let file_number = ...
let path = ...
*file_guard = ...| if let Some(guard) = latch_guard { | ||
| drop(guard); | ||
| latch_guard = None; | ||
| }; |
There was a problem hiding this comment.
if let Some(guard) = latch_guard.take() ?
| 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.
let Node::Leaf(leaf_node) = &mut *leaf else {
unreachable!()
}| } | ||
|
|
||
| impl< | ||
| K: Default + Ord + Clone + Debug + Sized + Serialize + for<'de> Deserialize<'de> + Sync + Send, |
There was a problem hiding this comment.
добавь алиас на этот набор трейтов, как сделано с ChunkHash например
| }) | ||
| .collect(); | ||
|
|
||
| let keys = futures::future::join_all(key_futures).await; |
There was a problem hiding this comment.
в токио вроде такая же штука есть, зачем futures?
There was a problem hiding this comment.
В токио же нету join_all? вручную придется каждый future эвэйтить и в ключи добавлять, так удобнее просто
No description provided.