Skip to content

Commit

Permalink
KG-4574: Allow replacing edges for faster diff manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
DGPardo committed Nov 4, 2024
1 parent 0da9758 commit f514050
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ no-skip-if = []

[dependencies]
bincode = { version = "1.3.3" }
hashbrown = { version = "0.14.0", features = ["serde"] }
hashbrown = { version = "0.15.0", features = ["serde"] }
pyo3 = { version = "0.21.2", features = ["extension-module"], optional = true}
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1.0.0" }
Expand Down
8 changes: 8 additions & 0 deletions src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ impl<Id: Hash + Eq + Copy, T: Default + AddAssign, W: Copy + PartialEq> GraphDif
Ok(())
}

/// # Safety
/// Does not check that the node IDs are valid (i.e. not marked as deleted).
/// CAUTION: This replaces the edge-diff by the provided one, potentially making `self`
/// internally inconsistent.
pub unsafe fn set_edges_unchecked(&mut self, edges: HashMap<Id, HashMap<Id, W>>) {
self.edges.new_or_updated = edges;
}

/// Add a new edge to be deleted to the diff.
/// If present, the edge is removed from `new_or_updated`.
pub fn delete_edge(&mut self, from: &Id, to: &Id) {
Expand Down

0 comments on commit f514050

Please sign in to comment.