Skip to content

Commit

Permalink
address some issues with the review
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Dec 17, 2024
1 parent 8c24146 commit 03ab131
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 81 deletions.
39 changes: 3 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ debug = 0

[workspace.dependencies]
#[public-storage]
# pometry-storage = { version = ">=0.8.1", path = "pometry-storage" }
pometry-storage = { version = ">=0.8.1", path = "pometry-storage" }
#[private-storage]
pometry-storage = { path = "pometry-storage-private", package = "pometry-storage-private" }
# pometry-storage = { path = "pometry-storage-private", package = "pometry-storage-private" }
async-graphql = { version = "7.0.13", features = ["dynamic-schema"] }
bincode = "1.3.3"
async-graphql-poem = "7.0.13"
Expand Down
2 changes: 1 addition & 1 deletion pometry-storage-private
8 changes: 4 additions & 4 deletions raphtory/src/core/entities/nodes/node_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::core::{
properties::{props::Props, tcell::TCell},
LayerIds, EID, GID, VID,
},
storage::{lazy_vec::IllegalSet, timeindex::TimeIndexEntry, ArcEntry, NodeEntry},
storage::{lazy_vec::IllegalSet, timeindex::TimeIndexEntry, ArcNodeEntry, NodeEntry},
utils::{errors::GraphError, iter::GenLockedIter},
Direction, Prop,
};
Expand Down Expand Up @@ -302,7 +302,7 @@ impl NodeStore {
}
}

impl ArcEntry {
impl ArcNodeEntry {
pub fn into_edges(self, layers: &LayerIds, dir: Direction) -> impl Iterator<Item = EdgeRef> {
GenLockedIter::from(self, |node| {
node.get_entry().node().edge_tuples(layers, dir)
Expand Down Expand Up @@ -363,7 +363,7 @@ impl<'a> NodeEntry<'a> {
}

pub struct LockedLayers {
entry: ArcEntry,
entry: ArcNodeEntry,
pos: usize,
len: usize,
}
Expand All @@ -390,7 +390,7 @@ impl Iterator for LockedLayers {
}

pub struct LockedLayer {
entry: ArcEntry,
entry: ArcNodeEntry,
offset: usize,
}

Expand Down
18 changes: 9 additions & 9 deletions raphtory/src/core/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ impl ReadLockedStorage {
}

#[inline]
pub(crate) fn arc_entry(&self, index: VID) -> ArcEntry {
pub(crate) fn arc_entry(&self, index: VID) -> ArcNodeEntry {
let (bucket, offset) = self.resolve(index);
ArcEntry {
ArcNodeEntry {
guard: self.locks[bucket].clone(),
i: offset,
}
Expand All @@ -465,9 +465,9 @@ impl ReadLockedStorage {
}

#[cfg(test)]
pub(crate) fn into_iter(self) -> impl Iterator<Item = ArcEntry> {
pub(crate) fn into_iter(self) -> impl Iterator<Item = ArcNodeEntry> {
self.locks.into_iter().flat_map(|data| {
(0..data.as_ref().len()).map(move |offset| ArcEntry {
(0..data.as_ref().len()).map(move |offset| ArcNodeEntry {
guard: data.clone(),
i: offset,
})
Expand Down Expand Up @@ -550,12 +550,12 @@ impl NodeStorage {
NodeEntry { offset, guard }
}

pub fn entry_arc(&self, index: VID) -> ArcEntry {
pub fn entry_arc(&self, index: VID) -> ArcNodeEntry {
let index = index.into();
let (bucket, offset) = self.resolve(index);
let guard = &self.data[bucket].data;
let arc_guard = RwLock::read_arc_recursive(guard);
ArcEntry {
ArcNodeEntry {
i: offset,
guard: Arc::new(arc_guard),
}
Expand Down Expand Up @@ -765,19 +765,19 @@ impl NodeEntry<'_> {
}

#[derive(Debug)]
pub struct ArcEntry {
pub struct ArcNodeEntry {
guard: Arc<ArcRwLockReadGuard<NodeSlot>>,
i: usize,
}

impl ArcEntry {
impl ArcNodeEntry {
#[inline]
pub fn get_entry(&self) -> NodePtr<'_> {
NodePtr::new(&self.guard[self.i], &self.guard.t_props_log)
}
}

impl Clone for ArcEntry {
impl Clone for ArcNodeEntry {
fn clone(&self) -> Self {
Self {
guard: self.guard.clone(),
Expand Down
4 changes: 2 additions & 2 deletions raphtory/src/db/api/storage/graph/nodes/node_owned_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use either::Either;
use crate::{
core::{
entities::{edges::edge_ref::EdgeRef, LayerIds},
storage::ArcEntry,
storage::ArcNodeEntry,
Direction,
},
db::api::storage::graph::nodes::node_storage_ops::NodeStorageIntoOps,
};

pub enum NodeOwnedEntry {
Mem(ArcEntry),
Mem(ArcNodeEntry),
#[cfg(feature = "storage")]
Disk(DiskOwnedNode),
}
Expand Down
4 changes: 2 additions & 2 deletions raphtory/src/db/api/storage/graph/nodes/node_storage_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::borrow::Cow;
use crate::{
core::{
entities::{edges::edge_ref::EdgeRef, GidRef, LayerIds, VID},
storage::ArcEntry,
storage::ArcNodeEntry,
Direction,
},
db::api::{storage::graph::tprop_storage_ops::TPropOps, view::internal::NodeAdditions},
Expand Down Expand Up @@ -47,7 +47,7 @@ pub trait NodeStorageIntoOps: Sized {
}
}

impl NodeStorageIntoOps for ArcEntry {
impl NodeStorageIntoOps for ArcNodeEntry {
fn into_edges_iter(self, layers: LayerIds, dir: Direction) -> impl Iterator<Item = EdgeRef> {
self.into_edges(&layers, dir)
}
Expand Down
7 changes: 0 additions & 7 deletions raphtory/src/db/api/view/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,6 @@ impl<'graph, G: BoxableGraphView + Sized + Clone + 'graph> GraphViewOps<'graph>
}
g.logical_to_physical.set(gid.as_ref(), new_id)?;

if let Some(earliest) = node.earliest_time() {
// explicitly add node earliest_time to handle PersistentGraph
new_node
.node_store_mut()
.update_t_prop_time(TimeIndexEntry::start(earliest), None)
}

for (t, rows) in node.rows() {
let prop_offset = new_node.t_props_log_mut().push(rows)?;
new_node.node_store_mut().update_t_prop_time(t, prop_offset);
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/db/api/view/node_property_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ mod test {
#[test]
fn test_filter_is_none() {
proptest!(|(
edges in build_edge_list(2, 10), nodes in build_node_props(50)
edges in build_edge_list(100, 100), nodes in build_node_props(100)
)| {
let g = build_graph_from_edge_list(&edges);
add_node_props(&g, &nodes);
Expand Down
6 changes: 4 additions & 2 deletions raphtory/src/db/graph/views/deletion_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,16 @@ mod test_deletions {

#[test]
fn test_materialize_window_node_props() {
let g = PersistentGraph::new();
let g = Graph::new();
g.add_node(0, 1, [("test", "test")], None).unwrap();

test_storage!(&g, |g| {
let g = g.persistent_graph();

let wg = g.window(3, 5);
let mg = wg.materialize().unwrap();
assert_graph_equal(&wg, &mg);
})
});
}

#[test]
Expand Down
12 changes: 3 additions & 9 deletions raphtory/src/db/graph/views/window_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,7 @@ impl<'graph, G: GraphViewOps<'graph>> TimeSemantics for WindowedGraph<G> {
if self.window_is_empty() {
return Box::new(std::iter::empty());
}
let range = w
.map(|r| r.start..r.end)
.unwrap_or_else(|| self.start_bound()..self.end_bound());
let range = w.unwrap_or_else(|| self.start_bound()..self.end_bound());
self.graph.node_edge_history(v, Some(range))
}

Expand All @@ -359,9 +357,7 @@ impl<'graph, G: GraphViewOps<'graph>> TimeSemantics for WindowedGraph<G> {
return Box::new(std::iter::empty());
}

let range = w
.map(|r| r.start..r.end)
.unwrap_or_else(|| self.start_bound()..self.end_bound());
let range = w.unwrap_or_else(|| self.start_bound()..self.end_bound());
self.graph.node_property_history(v, Some(range))
}

Expand All @@ -373,9 +369,7 @@ impl<'graph, G: GraphViewOps<'graph>> TimeSemantics for WindowedGraph<G> {
if self.window_is_empty() {
return Box::new(std::iter::empty());
}
let range = w
.map(|r| r.start..r.end)
.unwrap_or_else(|| self.start_bound()..self.end_bound());
let range = w.unwrap_or_else(|| self.start_bound()..self.end_bound());
self.graph.node_history_rows(v, Some(range))
}

Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/disk_graph/graph_impl/tprops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};
use pometry_storage::{
chunked_array::{bool_col::ChunkedBoolCol, col::ChunkedPrimitiveCol, utf8_col::StringCol},
prelude::{ArrayOps, BaseArrayOps},
prelude::ArrayOps,
tprops::{DiskTProp, EmptyTProp, TPropColumn},
};
use raphtory_api::core::storage::timeindex::TimeIndexEntry;
Expand Down
12 changes: 7 additions & 5 deletions raphtory/src/disk_graph/storage_interface/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ impl<'a> DiskNode<'a> {

pub fn last_before_row(self, t: TimeIndexEntry) -> Vec<(usize, Prop)> {
self.graph
.node_properties()
.temporal_props()
.prop_mapping()
.nodes()
.into_iter()
.enumerate()
.filter_map(|(layer, props)| {
let ts = props.timestamps::<TimeIndexEntry>(self.vid);
let idx = ts.last_before(t)?;
.filter_map(|(prop_id, &location)| {
let (layer, local_prop_id) = location?;
let layer = self.graph().node_properties().temporal_props().get(layer)?;
let t_prop = layer.prop::<TimeIndexEntry>(self.vid, local_prop_id);
t_prop.last_before(t).map(|(_, p)| (prop_id, p))
})
.collect()
}
Expand Down

0 comments on commit 03ab131

Please sign in to comment.