Skip to content

Commit 30f653c

Browse files
committed
Refactor ResultTransformerBuilder
1 parent 5b534e8 commit 30f653c

File tree

32 files changed

+113
-159
lines changed

32 files changed

+113
-159
lines changed

algorithms-compute-business-facade/src/main/java/org/neo4j/gds/pathfinding/PathFindingComputeBusinessFacade.java

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,12 @@ public <TR> CompletableFuture<TR> allShortestPaths(
109109
databaseId
110110
);
111111
var graph = graphResources.graph();
112-
var graphStore = graphResources.graphStore();
113112

114113
return computeFacade.allShortestPaths(
115114
graph,
116115
parameters,
117116
jobId
118-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
117+
).thenApply(resultTransformerBuilder.build(graphResources));
119118
}
120119

121120
public <TR> CompletableFuture<TR> bellmanFord(
@@ -138,14 +137,13 @@ public <TR> CompletableFuture<TR> bellmanFord(
138137
databaseId
139138
);
140139
var graph = graphResources.graph();
141-
var graphStore = graphResources.graphStore();
142140

143141
return computeFacade.bellmanFord(
144142
graph,
145143
parameters,
146144
jobId,
147145
logProgress
148-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
146+
).thenApply(resultTransformerBuilder.build(graphResources));
149147
}
150148

151149
public <TR> CompletableFuture<TR> breadthFirstSearch(
@@ -170,14 +168,13 @@ public <TR> CompletableFuture<TR> breadthFirstSearch(
170168
databaseId
171169
);
172170
var graph = graphResources.graph();
173-
var graphStore = graphResources.graphStore();
174171

175172
return computeFacade.breadthFirstSearch(
176173
graph,
177174
parameters,
178175
jobId,
179176
logProgress
180-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
177+
).thenApply(resultTransformerBuilder.build(graphResources));
181178
}
182179

183180
public <TR> CompletableFuture<TR> deltaStepping(
@@ -200,14 +197,13 @@ public <TR> CompletableFuture<TR> deltaStepping(
200197
databaseId
201198
);
202199
var graph = graphResources.graph();
203-
var graphStore = graphResources.graphStore();
204200

205201
return computeFacade.deltaStepping(
206202
graph,
207203
parameters,
208204
jobId,
209205
logProgress
210-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
206+
).thenApply(resultTransformerBuilder.build(graphResources));
211207
}
212208

213209
public <TR> CompletableFuture<TR> depthFirstSearch(
@@ -232,14 +228,13 @@ public <TR> CompletableFuture<TR> depthFirstSearch(
232228
databaseId
233229
);
234230
var graph = graphResources.graph();
235-
var graphStore = graphResources.graphStore();
236231

237232
return computeFacade.depthFirstSearch(
238233
graph,
239234
parameters,
240235
jobId,
241236
logProgress
242-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
237+
).thenApply(resultTransformerBuilder.build(graphResources));
243238
}
244239

245240
public <TR> CompletableFuture<TR> kSpanningTree(
@@ -262,14 +257,13 @@ public <TR> CompletableFuture<TR> kSpanningTree(
262257
databaseId
263258
);
264259
var graph = graphResources.graph();
265-
var graphStore = graphResources.graphStore();
266260

267261
return computeFacade.kSpanningTree(
268262
graph,
269263
parameters,
270264
jobId,
271265
logProgress
272-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
266+
).thenApply(resultTransformerBuilder.build(graphResources));
273267
}
274268

275269
public <TR> CompletableFuture<TR> longestPath(
@@ -291,14 +285,13 @@ public <TR> CompletableFuture<TR> longestPath(
291285
databaseId
292286
);
293287
var graph = graphResources.graph();
294-
var graphStore = graphResources.graphStore();
295288

296289
return computeFacade.longestPath(
297290
graph,
298291
parameters,
299292
jobId,
300293
logProgress
301-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
294+
).thenApply(resultTransformerBuilder.build(graphResources));
302295
}
303296

304297
public <TR> CompletableFuture<TR> randomWalk(
@@ -321,14 +314,13 @@ public <TR> CompletableFuture<TR> randomWalk(
321314
databaseId
322315
);
323316
var graph = graphResources.graph();
324-
var graphStore = graphResources.graphStore();
325317

326318
return computeFacade.randomWalk(
327319
graph,
328320
parameters,
329321
jobId,
330322
logProgress
331-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
323+
).thenApply(resultTransformerBuilder.build(graphResources));
332324
}
333325

334326
public <TR> CompletableFuture<TR> randomWalkCountingNodeVisits(
@@ -351,14 +343,13 @@ public <TR> CompletableFuture<TR> randomWalkCountingNodeVisits(
351343
databaseId
352344
);
353345
var graph = graphResources.graph();
354-
var graphStore = graphResources.graphStore();
355346

356347
return computeFacade.randomWalkCountingNodeVisits(
357348
graph,
358349
parameters,
359350
jobId,
360351
logProgress
361-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
352+
).thenApply(resultTransformerBuilder.build(graphResources));
362353
}
363354

364355
public <TR> CompletableFuture<TR> pcst(
@@ -382,15 +373,14 @@ public <TR> CompletableFuture<TR> pcst(
382373
);
383374

384375
var graph = graphResources.graph();
385-
var graphStore = graphResources.graphStore();
386376

387377

388378
return computeFacade.pcst(
389379
graph,
390380
parameters,
391381
jobId,
392382
logProgress
393-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
383+
).thenApply(resultTransformerBuilder.build(graphResources));
394384
}
395385

396386
public <TR> CompletableFuture<TR> singlePairShortestPathAStar(
@@ -413,14 +403,13 @@ public <TR> CompletableFuture<TR> singlePairShortestPathAStar(
413403
databaseId
414404
);
415405
var graph = graphResources.graph();
416-
var graphStore = graphResources.graphStore();
417406

418407
return computeFacade.singlePairShortestPathAStar(
419408
graph,
420409
parameters,
421410
jobId,
422411
logProgress
423-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
412+
).thenApply(resultTransformerBuilder.build(graphResources));
424413
}
425414

426415
public <TR> CompletableFuture<TR> singlePairShortestPathDijkstra(
@@ -443,14 +432,13 @@ public <TR> CompletableFuture<TR> singlePairShortestPathDijkstra(
443432
databaseId
444433
);
445434
var graph = graphResources.graph();
446-
var graphStore = graphResources.graphStore();
447435

448436
return computeFacade.singlePairShortestPathDijkstra(
449437
graph,
450438
parameters,
451439
jobId,
452440
logProgress
453-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
441+
).thenApply(resultTransformerBuilder.build(graphResources));
454442
}
455443

456444
public <TR> CompletableFuture<TR> singlePairShortestPathYens(
@@ -473,14 +461,13 @@ public <TR> CompletableFuture<TR> singlePairShortestPathYens(
473461
databaseId
474462
);
475463
var graph = graphResources.graph();
476-
var graphStore = graphResources.graphStore();
477464

478465
return computeFacade.singlePairShortestPathYens(
479466
graph,
480467
parameters,
481468
jobId,
482469
logProgress
483-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
470+
).thenApply(resultTransformerBuilder.build(graphResources));
484471
}
485472

486473
public <TR> CompletableFuture<TR> singleSourceShortestPathDijkstra(
@@ -503,14 +490,13 @@ public <TR> CompletableFuture<TR> singleSourceShortestPathDijkstra(
503490
databaseId
504491
);
505492
var graph = graphResources.graph();
506-
var graphStore = graphResources.graphStore();
507493

508494
return computeFacade.singleSourceShortestPathDijkstra(
509495
graph,
510496
parameters,
511497
jobId,
512498
logProgress
513-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
499+
).thenApply(resultTransformerBuilder.build(graphResources));
514500
}
515501

516502
public <TR> CompletableFuture<TR> spanningTree(
@@ -533,14 +519,13 @@ public <TR> CompletableFuture<TR> spanningTree(
533519
databaseId
534520
);
535521
var graph = graphResources.graph();
536-
var graphStore = graphResources.graphStore();
537522

538523
return computeFacade.spanningTree(
539524
graph,
540525
parameters,
541526
jobId,
542527
logProgress
543-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
528+
).thenApply(resultTransformerBuilder.build(graphResources));
544529
}
545530

546531
public <TR> CompletableFuture<TR> steinerTree(
@@ -563,14 +548,13 @@ public <TR> CompletableFuture<TR> steinerTree(
563548
databaseId
564549
);
565550
var graph = graphResources.graph();
566-
var graphStore = graphResources.graphStore();
567551

568552
return computeFacade.steinerTree(
569553
graph,
570554
parameters,
571555
jobId,
572556
logProgress
573-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
557+
).thenApply(resultTransformerBuilder.build(graphResources));
574558
}
575559

576560
public <TR> CompletableFuture<TR> topologicalSort(
@@ -592,13 +576,12 @@ public <TR> CompletableFuture<TR> topologicalSort(
592576
databaseId
593577
);
594578
var graph = graphResources.graph();
595-
var graphStore = graphResources.graphStore();
596579

597580
return computeFacade.topologicalSort(
598581
graph,
599582
parameters,
600583
jobId,
601584
logProgress
602-
).thenApply(resultTransformerBuilder.build(graph, graphStore));
585+
).thenApply(resultTransformerBuilder.build(graphResources));
603586
}
604587
}

algorithms-compute-business-facade/src/main/java/org/neo4j/gds/results/ResultTransformerBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
*/
2020
package org.neo4j.gds.results;
2121

22-
import org.neo4j.gds.api.Graph;
23-
import org.neo4j.gds.api.GraphStore;
22+
import org.neo4j.gds.core.loading.GraphResources;
2423

2524
public interface ResultTransformerBuilder<AR, TR> {
26-
ResultTransformer<AR, TR> build(Graph graph, GraphStore graphStore);
25+
ResultTransformer<AR, TR> build(GraphResources graphResources);
2726
}

procedures/pushback-procedures-facade/src/main/java/org/neo4j/gds/procedures/algorithms/pathfinding/mutate/BellmanFordMutateResultTransformerBuilder.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
*/
2020
package org.neo4j.gds.procedures.algorithms.pathfinding.mutate;
2121

22-
import org.neo4j.gds.api.Graph;
23-
import org.neo4j.gds.api.GraphStore;
2422
import org.neo4j.gds.applications.algorithms.machinery.MutateRelationshipService;
23+
import org.neo4j.gds.core.loading.GraphResources;
2524
import org.neo4j.gds.pathfinding.BellmanFordMutateStep;
2625
import org.neo4j.gds.paths.bellmanford.AllShortestPathsBellmanFordMutateConfig;
2726
import org.neo4j.gds.paths.bellmanford.BellmanFordResult;
@@ -46,8 +45,7 @@ class BellmanFordMutateResultTransformerBuilder implements ResultTransformerBuil
4645

4746
@Override
4847
public BellmanFordMutateResultTransformer build(
49-
Graph graph,
50-
GraphStore graphStore
48+
GraphResources graphResources
5149
) {
5250
var mutateStep = new BellmanFordMutateStep(
5351
configuration.mutateRelationshipType(),
@@ -56,8 +54,8 @@ public BellmanFordMutateResultTransformer build(
5654
);
5755
return new BellmanFordMutateResultTransformer(
5856
mutateStep,
59-
graph,
60-
graphStore,
57+
graphResources.graph(),
58+
graphResources.graphStore(),
6159
configuration.toMap()
6260
);
6361
}

procedures/pushback-procedures-facade/src/main/java/org/neo4j/gds/procedures/algorithms/pathfinding/mutate/PathFindingMutateResultTransformerBuilder.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
*/
2020
package org.neo4j.gds.procedures.algorithms.pathfinding.mutate;
2121

22-
import org.neo4j.gds.api.Graph;
23-
import org.neo4j.gds.api.GraphStore;
2422
import org.neo4j.gds.applications.algorithms.machinery.MutateRelationshipService;
2523
import org.neo4j.gds.config.MutateRelationshipConfig;
24+
import org.neo4j.gds.core.loading.GraphResources;
2625
import org.neo4j.gds.pathfinding.ShortestPathMutateStep;
2726
import org.neo4j.gds.paths.dijkstra.PathFindingResult;
2827
import org.neo4j.gds.procedures.algorithms.pathfinding.PathFindingMutateResult;
@@ -46,17 +45,16 @@ class PathFindingMutateResultTransformerBuilder implements ResultTransformerBuil
4645

4746
@Override
4847
public PathFindingMutateResultTransformer build(
49-
Graph graph,
50-
GraphStore graphStore
48+
GraphResources graphResources
5149
) {
5250
var mutateStep = new ShortestPathMutateStep(
5351
configuration.mutateRelationshipType(),
5452
mutateRelationshipService
5553
);
5654
return new PathFindingMutateResultTransformer(
5755
mutateStep,
58-
graph,
59-
graphStore,
56+
graphResources.graph(),
57+
graphResources.graphStore(),
6058
configuration.toMap()
6159
);
6260
}

procedures/pushback-procedures-facade/src/main/java/org/neo4j/gds/procedures/algorithms/pathfinding/mutate/PrizeSteinerMutateResultTransformerBuilder.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
*/
2020
package org.neo4j.gds.procedures.algorithms.pathfinding.mutate;
2121

22-
import org.neo4j.gds.api.Graph;
23-
import org.neo4j.gds.api.GraphStore;
2422
import org.neo4j.gds.applications.algorithms.machinery.MutateRelationshipService;
23+
import org.neo4j.gds.core.loading.GraphResources;
2524
import org.neo4j.gds.pathfinding.PrizeCollectingSteinerTreeMutateStep;
2625
import org.neo4j.gds.pcst.PCSTMutateConfig;
2726
import org.neo4j.gds.pricesteiner.PrizeSteinerTreeResult;
@@ -46,8 +45,7 @@ class PrizeSteinerMutateResultTransformerBuilder implements ResultTransformerBui
4645

4746
@Override
4847
public PrizeSteinerTreeMutateResultTransformer build(
49-
Graph graph,
50-
GraphStore graphStore
48+
GraphResources graphResources
5149
) {
5250
var mutateStep = new PrizeCollectingSteinerTreeMutateStep(
5351
configuration.mutateRelationshipType(),
@@ -56,8 +54,8 @@ public PrizeSteinerTreeMutateResultTransformer build(
5654
);
5755
return new PrizeSteinerTreeMutateResultTransformer(
5856
mutateStep,
59-
graph,
60-
graphStore,
57+
graphResources.graph(),
58+
graphResources.graphStore(),
6159
configuration.toMap()
6260
);
6361
}

0 commit comments

Comments
 (0)