diff --git a/Cargo.toml b/Cargo.toml index cf3c4621f..4c34bc14a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ readme = "README.md" homepage = "https://github.com/Raphtory/raphtory/" keywords = ["graph", "temporal-graph", "temporal"] authors = ["Pometry"] -rust-version = "1.84.0" +rust-version = "1.82.0" edition = "2021" [profile.dev] diff --git a/raphtory/src/db/api/storage/graph/storage_ops/mod.rs b/raphtory/src/db/api/storage/graph/storage_ops/mod.rs index a127d225d..deae19f62 100644 --- a/raphtory/src/db/api/storage/graph/storage_ops/mod.rs +++ b/raphtory/src/db/api/storage/graph/storage_ops/mod.rs @@ -107,14 +107,25 @@ impl std::fmt::Display for GraphStorage { } impl GraphStorage { - /// Unique id for the storage that can be used to check if two views point at the same underlying - /// graph (and hence have compatible VIDs) - pub fn graph_id(&self) -> usize { + /// Check if two storage instances point at the same underlying storage + pub fn ptr_eq(&self, other: &Self) -> bool { match self { - GraphStorage::Mem(g) => Arc::as_ptr(&g.graph).addr(), - GraphStorage::Unlocked(g) => Arc::as_ptr(g).addr(), + GraphStorage::Mem(LockedGraph { + graph: this_graph, .. + }) + | GraphStorage::Unlocked(this_graph) => match other { + GraphStorage::Mem(LockedGraph { + graph: other_graph, .. + }) + | GraphStorage::Unlocked(other_graph) => Arc::ptr_eq(this_graph, other_graph), + #[cfg(feature = "storage")] + _ => false, + }, #[cfg(feature = "storage")] - GraphStorage::Disk(g) => Arc::as_ptr(g).addr(), + GraphStorage::Disk(this_graph) => match other { + GraphStorage::Disk(other_graph) => Arc::ptr_eq(this_graph, other_graph), + _ => false, + }, } } diff --git a/raphtory/src/db/api/view/internal/core_ops.rs b/raphtory/src/db/api/view/internal/core_ops.rs index 8345ad717..8cf35147c 100644 --- a/raphtory/src/db/api/view/internal/core_ops.rs +++ b/raphtory/src/db/api/view/internal/core_ops.rs @@ -37,6 +37,11 @@ use std::{iter, ops::Range}; #[cfg(feature = "storage")] use pometry_storage::timestamps::LayerAdditions; +/// Check if two Graph views point at the same underlying storage +pub fn is_view_compatible(g1: &impl CoreGraphOps, g2: &impl CoreGraphOps) -> bool { + g1.core_graph().ptr_eq(&g2.core_graph()) +} + /// Core functions that should (almost-)always be implemented by pointing at the underlying graph. #[enum_dispatch] pub trait CoreGraphOps: Send + Sync { diff --git a/raphtory/src/db/graph/nodes.rs b/raphtory/src/db/graph/nodes.rs index bd8ad08e0..6f40f592f 100644 --- a/raphtory/src/db/graph/nodes.rs +++ b/raphtory/src/db/graph/nodes.rs @@ -15,7 +15,10 @@ use crate::{ }; use crate::db::{ - api::state::{Index, NodeOp}, + api::{ + state::{Index, NodeOp}, + view::internal::is_view_compatible, + }, graph::{create_node_type_filter, views::node_subgraph::NodeSubgraph}, }; use either::Either; @@ -69,7 +72,7 @@ impl<'graph, G: GraphViewOps<'graph>, GH: GraphViewOps<'graph> + Debug> Debug impl<'graph, G: GraphViewOps<'graph>, GH: GraphViewOps<'graph>> PartialEq for Nodes<'graph, G, GH> { fn eq(&self, other: &Self) -> bool { - if self.base_graph.core_graph().graph_id() == other.base_graph.core_graph().graph_id() { + if is_view_compatible(&self.base_graph, &other.base_graph) { // same storage, can use internal ids self.iter_refs().eq(other.iter_refs()) } else {