-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
When implementing join, I can do many things using very fast radix tree ops. E.g. removing expired from the store can be done with a single tree op instead of a loop.
E.g. this loop
for buf in causal.store.iter() {
let path = buf.as_path();
if !self.expired.contains_prefix(path) && !causal.expired.contains_prefix(path) {
if !self.can(peer, Permission::Write, path)? {
tracing::info!("join: peer is unauthorized to insert {}", path);
continue;
}
self.store.insert(&path);
}
}can be turned into this:
let mut store = causal.store.clone();
store.tree_mut().remove_prefix_with(&self.expired.tree());
store.tree_mut().remove_prefix_with(causal.expired.tree());
for buf in store.iter() {
let path = buf.as_path();
if !self.can(peer, Permission::Write, path)? {
tracing::info!("join: peer is unauthorized to insert {}", path);
continue;
}
self.store.insert(&path);
}However, operations that involve permissions at present still involve querying permissions for every path.
It would be quite useful if we had a way to produce a tree for a permission and a peer, and then perform bulk operations for that tree. This would not change except when permissions are changed.
E.g.
let writeable = self.writeable(peer, Permission::Write);
store.tree_mut().retain_prefix_with(&writeable);Metadata
Metadata
Assignees
Labels
No labels