Skip to content

Commit 0c61157

Browse files
Add EIDS to Node addition (#2279)
* added support for edge_history in LayerAdditions * eids added to node additions * add more simple tests * push the edge_history into the higher level APIs * fix broken test * added edge_history to NodeView * added tests for NodeView * chore: apply tidy-public auto-fixes * kmerge the slow edge history for nodes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent e3c8399 commit 0c61157

File tree

17 files changed

+480
-29
lines changed

17 files changed

+480
-29
lines changed

docs/reference/graphql/graphql_API.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,43 +2547,43 @@ This allows you to specify multiple operations together.
25472547
</thead>
25482548
<tbody>
25492549
<tr>
2550-
<td colspan="2" valign="top"><strong id="graphalgorithmplugin.pagerank">pagerank</strong></td>
2551-
<td valign="top">[<a href="#pagerankoutput">PagerankOutput</a>!]!</td>
2550+
<td colspan="2" valign="top"><strong id="graphalgorithmplugin.shortest_path">shortest_path</strong></td>
2551+
<td valign="top">[<a href="#shortestpathoutput">ShortestPathOutput</a>!]!</td>
25522552
<td></td>
25532553
</tr>
25542554
<tr>
2555-
<td colspan="2" align="right" valign="top">iterCount</td>
2556-
<td valign="top"><a href="#int">Int</a>!</td>
2555+
<td colspan="2" align="right" valign="top">source</td>
2556+
<td valign="top"><a href="#string">String</a>!</td>
25572557
<td></td>
25582558
</tr>
25592559
<tr>
2560-
<td colspan="2" align="right" valign="top">threads</td>
2561-
<td valign="top"><a href="#int">Int</a></td>
2560+
<td colspan="2" align="right" valign="top">targets</td>
2561+
<td valign="top">[<a href="#string">String</a>!]!</td>
25622562
<td></td>
25632563
</tr>
25642564
<tr>
2565-
<td colspan="2" align="right" valign="top">tol</td>
2566-
<td valign="top"><a href="#float">Float</a></td>
2565+
<td colspan="2" align="right" valign="top">direction</td>
2566+
<td valign="top"><a href="#string">String</a></td>
25672567
<td></td>
25682568
</tr>
25692569
<tr>
2570-
<td colspan="2" valign="top"><strong id="graphalgorithmplugin.shortest_path">shortest_path</strong></td>
2571-
<td valign="top">[<a href="#shortestpathoutput">ShortestPathOutput</a>!]!</td>
2570+
<td colspan="2" valign="top"><strong id="graphalgorithmplugin.pagerank">pagerank</strong></td>
2571+
<td valign="top">[<a href="#pagerankoutput">PagerankOutput</a>!]!</td>
25722572
<td></td>
25732573
</tr>
25742574
<tr>
2575-
<td colspan="2" align="right" valign="top">source</td>
2576-
<td valign="top"><a href="#string">String</a>!</td>
2575+
<td colspan="2" align="right" valign="top">iterCount</td>
2576+
<td valign="top"><a href="#int">Int</a>!</td>
25772577
<td></td>
25782578
</tr>
25792579
<tr>
2580-
<td colspan="2" align="right" valign="top">targets</td>
2581-
<td valign="top">[<a href="#string">String</a>!]!</td>
2580+
<td colspan="2" align="right" valign="top">threads</td>
2581+
<td valign="top"><a href="#int">Int</a></td>
25822582
<td></td>
25832583
</tr>
25842584
<tr>
2585-
<td colspan="2" align="right" valign="top">direction</td>
2586-
<td valign="top"><a href="#string">String</a></td>
2585+
<td colspan="2" align="right" valign="top">tol</td>
2586+
<td valign="top"><a href="#float">Float</a></td>
25872587
<td></td>
25882588
</tr>
25892589
</tbody>

pometry-storage-private

raphtory-api/src/core/storage/timeindex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ pub trait TimeIndexOps<'a>: Sized + Clone + Send + Sync + 'a {
5353

5454
#[inline]
5555
fn active_t(&self, w: Range<i64>) -> bool {
56-
self.active(Self::IndexType::range(w))
56+
self.active(<Self::IndexType as AsTime>::range(w))
5757
}
5858

5959
fn range(&self, w: Range<Self::IndexType>) -> Self::RangeType;
6060

6161
fn range_t(&self, w: Range<i64>) -> Self::RangeType {
62-
self.range(Self::IndexType::range(w))
62+
self.range(<Self::IndexType as AsTime>::range(w))
6363
}
6464

6565
fn first_t(&self) -> Option<i64> {

raphtory-cypher/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ mod cypher {
289289
let dsts = PrimitiveArray::from_vec(vec![3u64, 3u64, 4u64, 4u64]).boxed();
290290
let time = PrimitiveArray::from_vec(vec![2i64, 3i64, 4i64, 5i64]).boxed();
291291
let weight =
292-
PrimitiveArray::from_vec(vec![3.14f64, 4.14f64, 5.14f64, 6.14f64]).boxed();
292+
PrimitiveArray::from_vec(vec![3.15f64, 4.14f64, 5.14f64, 6.14f64]).boxed();
293293

294294
let chunk = StructArray::new(
295295
ArrowDataType::Struct(schema().fields),

raphtory-graphql/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,8 @@ type Graph {
940940
}
941941

942942
type GraphAlgorithmPlugin {
943-
pagerank(iterCount: Int!, threads: Int, tol: Float): [PagerankOutput!]!
944943
shortest_path(source: String!, targets: [String!]!, direction: String): [ShortestPathOutput!]!
944+
pagerank(iterCount: Int!, threads: Int, tol: Float): [PagerankOutput!]!
945945
}
946946

947947
type GraphSchema {

raphtory-storage/src/disk/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,16 @@ mod test {
511511

512512
let mut expected_node_additions = edges
513513
.iter()
514-
.flat_map(|(src, dst, t)| [(*src, *t), (*dst, *t)])
514+
.flat_map(|(src, dst, t)| {
515+
if src != dst {
516+
vec![(*src, *t), (*dst, *t)]
517+
} else {
518+
vec![(*src, *t)]
519+
}
520+
})
515521
.into_group_map();
516522
for v in expected_node_additions.values_mut() {
517523
v.sort();
518-
v.dedup();
519524
}
520525

521526
for (v_id, node) in nodes.iter().enumerate() {

raphtory/src/db/api/storage/graph/storage_ops/disk_storage.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,25 @@ mod storage_tests {
11731173
})
11741174
}
11751175

1176+
#[test]
1177+
fn test_merge_simple() {
1178+
let left = [(4, 4, 2), (4, 4, 2)];
1179+
let right = [];
1180+
inner_merge_test(&left, &right);
1181+
1182+
let left = [(0, 5, 5)];
1183+
let right = [];
1184+
inner_merge_test(&left, &right);
1185+
1186+
let left = [(0, 0, 0), (0, 0, 0), (0, 0, 0)];
1187+
let right = [];
1188+
inner_merge_test(&left, &right);
1189+
1190+
let left = [(0, 0, 0), (0, 0, 0), (0, 0, 0)];
1191+
let right = [(0, 0, 0)];
1192+
inner_merge_test(&left, &right);
1193+
}
1194+
11761195
#[test]
11771196
fn test_one_empty_graph_non_zero_time() {
11781197
inner_merge_test(&[], &[(1, 0, 0)])

raphtory/src/db/api/view/exploded_edge_property_filter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ mod test {
475475
.filter_exploded_edges(PropertyFilterBuilder::new("test").gt(0i64))
476476
.unwrap();
477477
let gfm = gf.materialize().unwrap();
478-
dbg!(&gfm);
479478
assert_eq!(gf.node(0).unwrap().out_degree(), 1);
480479
assert_eq!(gfm.node(0).unwrap().out_degree(), 1);
481480
assert_graph_equal(&gf, &gfm);

raphtory/src/db/api/view/internal/time_semantics/base_time_semantics.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,44 @@ impl NodeTimeSemanticsOps for BaseTimeSemantics {
112112
for_all!(self, semantics => semantics.node_edge_history_count(node, view))
113113
}
114114

115+
#[inline]
116+
fn node_edge_history<'graph, G: GraphView + 'graph>(
117+
self,
118+
node: NodeStorageRef<'graph>,
119+
view: G,
120+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
121+
for_all_iter!(self, semantics => semantics.node_edge_history(node, view))
122+
}
123+
124+
#[inline]
125+
fn node_edge_history_window<'graph, G: GraphView + 'graph>(
126+
self,
127+
node: NodeStorageRef<'graph>,
128+
view: G,
129+
w: Range<i64>,
130+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
131+
for_all_iter!(self, semantics => semantics.node_edge_history_window(node, view, w))
132+
}
133+
134+
#[inline]
135+
fn node_edge_history_rev<'graph, G: GraphView + 'graph>(
136+
self,
137+
node: NodeStorageRef<'graph>,
138+
view: G,
139+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
140+
for_all_iter!(self, semantics => semantics.node_edge_history_rev(node, view))
141+
}
142+
143+
#[inline]
144+
fn node_edge_history_rev_window<'graph, G: GraphView + 'graph>(
145+
self,
146+
node: NodeStorageRef<'graph>,
147+
view: G,
148+
w: Range<i64>,
149+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
150+
for_all_iter!(self, semantics => semantics.node_edge_history_rev_window(node, view, w))
151+
}
152+
115153
#[inline]
116154
fn node_edge_history_count_window<'graph, G: GraphView + 'graph>(
117155
self,

raphtory/src/db/api/view/internal/time_semantics/event_semantics.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,40 @@ impl NodeTimeSemanticsOps for EventSemantics {
9292
node.history(view).range_t(w).edge_history().len()
9393
}
9494

95+
fn node_edge_history<'graph, G: GraphView + 'graph>(
96+
self,
97+
node: NodeStorageRef<'graph>,
98+
view: G,
99+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
100+
node.edge_history(view).history()
101+
}
102+
103+
fn node_edge_history_window<'graph, G: GraphView + 'graph>(
104+
self,
105+
node: NodeStorageRef<'graph>,
106+
view: G,
107+
w: Range<i64>,
108+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
109+
node.edge_history(view).range_t(w).history()
110+
}
111+
112+
fn node_edge_history_rev<'graph, G: GraphView + 'graph>(
113+
self,
114+
node: NodeStorageRef<'graph>,
115+
view: G,
116+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
117+
node.edge_history(view).history_rev()
118+
}
119+
120+
fn node_edge_history_rev_window<'graph, G: GraphView + 'graph>(
121+
self,
122+
node: NodeStorageRef<'graph>,
123+
view: G,
124+
w: Range<i64>,
125+
) -> impl Iterator<Item = (TimeIndexEntry, ELID)> + Send + Sync + 'graph {
126+
node.edge_history(view).range_t(w).history_rev()
127+
}
128+
95129
fn node_updates<'graph, G: GraphView + 'graph>(
96130
self,
97131
node: NodeStorageRef<'graph>,

0 commit comments

Comments
 (0)