Skip to content

Commit

Permalink
Remove par iter from hot path (#1647)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu authored Jun 7, 2024
1 parent 571723d commit 1e984cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions raphtory/src/core/entities/edges/edge_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ impl EdgeStore {
LayerIds::None => false,
LayerIds::All => self
.additions
.par_iter()
.iter()
.any(|t_index| t_index.contains(w.clone())),
LayerIds::One(l_id) => self
.additions
.get(*l_id)
.map(|t_index| t_index.contains(w))
.unwrap_or(false),
LayerIds::Multiple(layers) => layers
.par_iter()
.iter()
.any(|l_id| self.active(&LayerIds::One(*l_id), w.clone())),
}
}
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/db/api/storage/edges/edge_storage_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl<'a> EdgeStorageOps<'a> for &'a EdgeStore {
LayerIds::None => false,
LayerIds::All => true,
LayerIds::One(id) => self.has_layer_inner(*id),
LayerIds::Multiple(ids) => ids.par_iter().any(|id| self.has_layer_inner(*id)),
LayerIds::Multiple(ids) => ids.iter().any(|id| self.has_layer_inner(*id)),
}
}

Expand Down
4 changes: 2 additions & 2 deletions raphtory/src/db/graph/views/deletion_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ fn alive_at<
}

fn edge_alive_at_end(e: EdgeStorageRef, t: i64, layer_ids: &LayerIds) -> bool {
e.updates_par_iter(layer_ids)
e.updates_iter(layer_ids)
.any(|(_, additions, deletions)| alive_before(&additions, &deletions, t))
}

fn edge_alive_at_start(e: EdgeStorageRef, t: i64, layer_ids: &LayerIds) -> bool {
// The semantics are tricky here, an edge is not alive at the start of the window if the first event at time t is a deletion
e.updates_par_iter(layer_ids)
e.updates_iter(layer_ids)
.any(|(_, additions, deletions)| alive_at(&additions, &deletions, t))
}

Expand Down

0 comments on commit 1e984cd

Please sign in to comment.