Skip to content

Conversation

@kamenkremen
Copy link
Owner

No description provided.

Copy link

@Piletskii-Oleg Piletskii-Oleg left a 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"

Choose a reason for hiding this comment

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

лучше tracing юзать


extern crate chunkfs;

/// Easily serializable version of BPlusTree

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> {

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> {

Choose a reason for hiding this comment

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

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

Copy link
Owner Author

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

Choose a reason for hiding this comment

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

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

Comment on lines 317 to 323
*file_guard = File::create(
self.path.join(
self.file_number
.load(std::sync::atomic::Ordering::SeqCst)
.to_string(),
),
)

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 on lines 369 to 372
if let Some(guard) = latch_guard {
drop(guard);
latch_guard = None;
};

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

None
let mut leaf = leaf_lock.write().await;
drop(prev_guard);
if let Node::Leaf(leaf_node) = &mut *leaf {

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

}

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

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;

Choose a reason for hiding this comment

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

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

Copy link
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 эвэйтить и в ключи добавлять, так удобнее просто

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.

3 participants