From f514050fe32ce3dcc7ecbecbbd1a77ee9f494155 Mon Sep 17 00:00:00 2001 From: DGPardo Date: Fri, 1 Nov 2024 18:13:33 +0000 Subject: [PATCH] KG-4574: Allow replacing edges for faster diff manipulation --- Cargo.toml | 2 +- src/diff.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f97c5bc..fa970ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/src/diff.rs b/src/diff.rs index 0e27393..29d64a3 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -216,6 +216,14 @@ impl 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>) { + 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) {