Skip to content

Merge async prototype#3

Merged
kamenkremen merged 22 commits into
mainfrom
PrototypeAsync
Jun 19, 2025
Merged

Merge async prototype#3
kamenkremen merged 22 commits into
mainfrom
PrototypeAsync

Conversation

@kamenkremen

Copy link
Copy Markdown
Owner

No description provided.

@Piletskii-Oleg Piletskii-Oleg left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

верю что работает

Comment thread Cargo.toml Outdated
rand = "0.8.5"
tokio = { version = "1.44.2", features = ["full"] }
env_logger = "0.11.8"
log = "0.4.27"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше tracing юзать

Comment thread src/bplus_tree.rs Outdated

extern crate chunkfs;

/// Easily serializable version of BPlusTree

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

она не easily, она просто serializable

Comment thread src/bplus_tree.rs
}

impl<K: Clone + Send + Sync> BPlus<K> {
async fn serialize(&self) -> SerializableBPlus<K> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше написать что этот метод возвращает сериализуемое дерево

Comment thread src/bplus_tree.rs

impl<K: Clone + Send + Sync> Node<K> {
#[async_recursion]
async fn serialize(&self) -> SerializableNode<K> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну и тут тоже. оно аллоцирует новое дерево по сути и это хотелось бы знать. а вообще насколько это правильный подход, клонировать все дерево, чтобы его сериализовать?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я думаю не очень правильный, но лучше я не успеваю сделать, так что пусть пока хотя бы как-то работает

Comment thread src/bplus_tree.rs
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

разные предложения надо отделять либо точками либо целыми пустыми строками

Comment thread src/bplus_tree.rs Outdated
Comment on lines +317 to +323
*file_guard = File::create(
self.path.join(
self.file_number
.load(std::sync::atomic::Ordering::SeqCst)
.to_string(),
),
)

Copy link
Copy Markdown

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 = ...

Comment thread src/bplus_tree.rs Outdated
Comment on lines +369 to +372
if let Some(guard) = latch_guard {
drop(guard);
latch_guard = None;
};

Copy link
Copy Markdown

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() ?

Comment thread src/bplus_tree.rs Outdated
None
let mut leaf = leaf_lock.write().await;
drop(prev_guard);
if let Node::Leaf(leaf_node) = &mut *leaf {

Copy link
Copy Markdown

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!()
}

Comment thread src/bplus_tree.rs Outdated
}

impl<
K: Default + Ord + Clone + Debug + Sized + Serialize + for<'de> Deserialize<'de> + Sync + Send,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавь алиас на этот набор трейтов, как сделано с ChunkHash например

Comment thread src/bplus_tree.rs
})
.collect();

let keys = futures::future::join_all(key_futures).await;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в токио вроде такая же штука есть, зачем futures?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В токио же нету join_all? вручную придется каждый future эвэйтить и в ключи добавлять, так удобнее просто

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а, действительно, ладно

@kamenkremen
kamenkremen merged commit 951d95b into main Jun 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants