diff --git a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsFacade.java b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsFacade.java index 82bff18d11..1068ea06ac 100644 --- a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsFacade.java +++ b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsFacade.java @@ -23,6 +23,7 @@ import org.neo4j.gds.core.utils.progress.TaskRegistryFactory; import org.neo4j.gds.core.write.RelationshipStreamExporterBuilder; import org.neo4j.gds.logging.Log; +import org.neo4j.gds.paths.SourceTargetShortestPathBaseConfig; import org.neo4j.gds.paths.astar.AStarMemoryEstimateDefinition; import org.neo4j.gds.paths.astar.config.ShortestPathAStarBaseConfig; import org.neo4j.gds.paths.astar.config.ShortestPathAStarMutateConfig; @@ -36,6 +37,7 @@ import org.neo4j.gds.paths.dijkstra.config.ShortestPathDijkstraStreamConfig; import org.neo4j.gds.paths.dijkstra.config.ShortestPathDijkstraWriteConfig; import org.neo4j.gds.paths.yens.YensMemoryEstimateDefinition; +import org.neo4j.gds.paths.yens.config.ShortestPathYensBaseConfig; import org.neo4j.gds.paths.yens.config.ShortestPathYensMutateConfig; import org.neo4j.gds.paths.yens.config.ShortestPathYensStreamConfig; import org.neo4j.gds.paths.yens.config.ShortestPathYensWriteConfig; @@ -160,6 +162,19 @@ public RESULT singlePairShortestPathAStarWrite( ); } + public MemoryEstimateResult singlePairShortestPathDijkstraEstimate( + SourceTargetShortestPathBaseConfig configuration, + Object graphNameOrConfiguration + ) { + var memoryEstimation = new DijkstraMemoryEstimateDefinition().memoryEstimation(configuration); + + return algorithmEstimationTemplate.estimate( + configuration, + graphNameOrConfiguration, + memoryEstimation + ); + } + public RESULT singlePairShortestPathDijkstraMutate( GraphName graphName, ShortestPathDijkstraMutateConfig configuration, @@ -218,6 +233,19 @@ public RESULT singlePairShortestPathDijkstraWrite( ); } + public MemoryEstimateResult singlePairShortestPathYensEstimate( + ShortestPathYensBaseConfig configuration, + Object graphNameOrConfiguration + ) { + var memoryEstimation = new YensMemoryEstimateDefinition().memoryEstimation(configuration); + + return algorithmEstimationTemplate.estimate( + configuration, + graphNameOrConfiguration, + memoryEstimation + ); + } + public RESULT singlePairShortestPathYensMutate( GraphName graphName, ShortestPathYensMutateConfig configuration, diff --git a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathAStarWriteProc.java b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathAStarWriteProc.java index ed022eb820..edaace1d74 100644 --- a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathAStarWriteProc.java +++ b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathAStarWriteProc.java @@ -19,10 +19,6 @@ */ package org.neo4j.gds.paths.sourcetarget; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.core.write.RelationshipStreamExporterBuilder; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.MemoryEstimationExecutor; import org.neo4j.gds.procedures.GraphDataScience; import org.neo4j.gds.results.MemoryEstimateResult; import org.neo4j.gds.results.StandardWriteRelationshipsResult; @@ -34,17 +30,15 @@ import java.util.Map; import java.util.stream.Stream; +import static org.neo4j.gds.ProcedureConstants.ESTIMATE_DESCRIPTION; import static org.neo4j.gds.paths.sourcetarget.SinglePairShortestPathConstants.ASTAR_DESCRIPTION; import static org.neo4j.procedure.Mode.READ; import static org.neo4j.procedure.Mode.WRITE; -public class ShortestPathAStarWriteProc extends BaseProc { +public class ShortestPathAStarWriteProc { @Context public GraphDataScience facade; - @Context - public RelationshipStreamExporterBuilder relationshipStreamExporterBuilder; - @Procedure(name = "gds.shortestPath.astar.write", mode = WRITE) @Description(ASTAR_DESCRIPTION) public Stream write( @@ -60,16 +54,9 @@ public Stream estimate( @Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration, @Name(value = "algoConfiguration") Map algoConfiguration ) { - return new MemoryEstimationExecutor<>( - new ShortestPathAStarWriteSpec(), - executionContext(), - transactionContext() - ).computeEstimate(graphNameOrConfiguration, algoConfiguration); + return facade.pathFinding().singlePairShortestPathAStarWriteEstimate( + graphNameOrConfiguration, + algoConfiguration + ); } - - @Override - public ExecutionContext executionContext() { - return super.executionContext().withRelationshipStreamExporterBuilder(relationshipStreamExporterBuilder); - } - } diff --git a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraMutateProc.java b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraMutateProc.java index 5d91405621..f685705c79 100644 --- a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraMutateProc.java +++ b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraMutateProc.java @@ -19,8 +19,6 @@ */ package org.neo4j.gds.paths.sourcetarget; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.executor.MemoryEstimationExecutor; import org.neo4j.gds.procedures.GraphDataScience; import org.neo4j.gds.procedures.pathfinding.PathFindingMutateResult; import org.neo4j.gds.results.MemoryEstimateResult; @@ -32,10 +30,11 @@ import java.util.Map; import java.util.stream.Stream; +import static org.neo4j.gds.ProcedureConstants.ESTIMATE_DESCRIPTION; import static org.neo4j.gds.paths.sourcetarget.SinglePairShortestPathConstants.DIJKSTRA_DESCRIPTION; import static org.neo4j.procedure.Mode.READ; -public class ShortestPathDijkstraMutateProc extends BaseProc { +public class ShortestPathDijkstraMutateProc { @Context public GraphDataScience facade; @@ -54,10 +53,9 @@ public Stream estimate( @Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration, @Name(value = "algoConfiguration") Map algoConfiguration ) { - return new MemoryEstimationExecutor<>( - new ShortestPathDijkstraMutateSpec(), - executionContext(), - transactionContext() - ).computeEstimate(graphNameOrConfiguration, algoConfiguration); + return facade.pathFinding().singlePairShortestPathDijkstraMutateEstimate( + graphNameOrConfiguration, + algoConfiguration + ); } } diff --git a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraStreamProc.java b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraStreamProc.java index d9a18652d2..5ab538b61a 100644 --- a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraStreamProc.java +++ b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraStreamProc.java @@ -19,10 +19,8 @@ */ package org.neo4j.gds.paths.sourcetarget; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.executor.MemoryEstimationExecutor; -import org.neo4j.gds.procedures.pathfinding.PathFindingStreamResult; import org.neo4j.gds.procedures.GraphDataScience; +import org.neo4j.gds.procedures.pathfinding.PathFindingStreamResult; import org.neo4j.gds.results.MemoryEstimateResult; import org.neo4j.procedure.Context; import org.neo4j.procedure.Description; @@ -32,10 +30,11 @@ import java.util.Map; import java.util.stream.Stream; +import static org.neo4j.gds.ProcedureConstants.ESTIMATE_DESCRIPTION; import static org.neo4j.gds.paths.sourcetarget.SinglePairShortestPathConstants.DIJKSTRA_DESCRIPTION; import static org.neo4j.procedure.Mode.READ; -public class ShortestPathDijkstraStreamProc extends BaseProc { +public class ShortestPathDijkstraStreamProc { @Context public GraphDataScience facade; @@ -54,13 +53,9 @@ public Stream estimate( @Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration, @Name(value = "algoConfiguration") Map algoConfiguration ) { - - return new MemoryEstimationExecutor<>( - new ShortestPathDijkstraStreamSpec(), - executionContext(), - transactionContext() - ).computeEstimate(graphNameOrConfiguration, algoConfiguration); + return facade.pathFinding().singlePairShortestPathDijkstraStreamEstimate( + graphNameOrConfiguration, + algoConfiguration + ); } - - } diff --git a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraWriteProc.java b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraWriteProc.java index a921026e59..de8722707c 100644 --- a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraWriteProc.java +++ b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathDijkstraWriteProc.java @@ -19,10 +19,6 @@ */ package org.neo4j.gds.paths.sourcetarget; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.core.write.RelationshipStreamExporterBuilder; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.MemoryEstimationExecutor; import org.neo4j.gds.procedures.GraphDataScience; import org.neo4j.gds.results.MemoryEstimateResult; import org.neo4j.gds.results.StandardWriteRelationshipsResult; @@ -34,17 +30,15 @@ import java.util.Map; import java.util.stream.Stream; +import static org.neo4j.gds.ProcedureConstants.ESTIMATE_DESCRIPTION; import static org.neo4j.gds.paths.sourcetarget.SinglePairShortestPathConstants.DIJKSTRA_DESCRIPTION; import static org.neo4j.procedure.Mode.READ; import static org.neo4j.procedure.Mode.WRITE; -public class ShortestPathDijkstraWriteProc extends BaseProc { +public class ShortestPathDijkstraWriteProc { @Context public GraphDataScience facade; - @Context - public RelationshipStreamExporterBuilder relationshipStreamExporterBuilder; - @Procedure(name = "gds.shortestPath.dijkstra.write", mode = WRITE) @Description(DIJKSTRA_DESCRIPTION) public Stream write( @@ -60,16 +54,9 @@ public Stream estimate( @Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration, @Name(value = "algoConfiguration") Map algoConfiguration ) { - return new MemoryEstimationExecutor<>( - new ShortestPathDijkstraWriteSpec(), - executionContext(), - transactionContext() - ).computeEstimate(graphNameOrConfiguration, algoConfiguration); + return facade.pathFinding().singlePairShortestPathDijkstraWriteEstimate( + graphNameOrConfiguration, + algoConfiguration + ); } - - @Override - public ExecutionContext executionContext() { - return super.executionContext().withRelationshipStreamExporterBuilder(relationshipStreamExporterBuilder); - } - } diff --git a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensMutateProc.java b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensMutateProc.java index 08fac6b3b2..d87dca1794 100644 --- a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensMutateProc.java +++ b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensMutateProc.java @@ -19,8 +19,6 @@ */ package org.neo4j.gds.paths.sourcetarget; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.executor.MemoryEstimationExecutor; import org.neo4j.gds.procedures.GraphDataScience; import org.neo4j.gds.procedures.pathfinding.PathFindingMutateResult; import org.neo4j.gds.results.MemoryEstimateResult; @@ -32,10 +30,11 @@ import java.util.Map; import java.util.stream.Stream; +import static org.neo4j.gds.ProcedureConstants.ESTIMATE_DESCRIPTION; import static org.neo4j.gds.paths.sourcetarget.SinglePairShortestPathConstants.YENS_DESCRIPTION; import static org.neo4j.procedure.Mode.READ; -public class ShortestPathYensMutateProc extends BaseProc { +public class ShortestPathYensMutateProc { @Context public GraphDataScience facade; @@ -54,10 +53,6 @@ public Stream estimate( @Name(value = "graphNameOrConfiguration") Object graphName, @Name(value = "algoConfiguration") Map configuration ) { - return new MemoryEstimationExecutor<>( - new ShortestPathYensMutateSpec(), - executionContext(), - transactionContext() - ).computeEstimate(graphName, configuration); + return facade.pathFinding().singlePairShortestPathYensMutateEstimate(graphName, configuration); } } diff --git a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensStreamProc.java b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensStreamProc.java index 27510a78f7..16b07cd138 100644 --- a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensStreamProc.java +++ b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensStreamProc.java @@ -19,8 +19,6 @@ */ package org.neo4j.gds.paths.sourcetarget; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.executor.MemoryEstimationExecutor; import org.neo4j.gds.procedures.GraphDataScience; import org.neo4j.gds.procedures.pathfinding.PathFindingStreamResult; import org.neo4j.gds.results.MemoryEstimateResult; @@ -32,10 +30,11 @@ import java.util.Map; import java.util.stream.Stream; +import static org.neo4j.gds.ProcedureConstants.ESTIMATE_DESCRIPTION; import static org.neo4j.gds.paths.sourcetarget.SinglePairShortestPathConstants.YENS_DESCRIPTION; import static org.neo4j.procedure.Mode.READ; -public class ShortestPathYensStreamProc extends BaseProc { +public class ShortestPathYensStreamProc { @Context public GraphDataScience facade; @@ -54,10 +53,6 @@ public Stream estimate( @Name(value = "graphName") Object graphName, @Name(value = "configuration") Map configuration ) { - return new MemoryEstimationExecutor<>( - new ShortestPathYensStreamSpec(), - executionContext(), - transactionContext() - ).computeEstimate(graphName, configuration); + return facade.pathFinding().singlePairShortestPathYensStreamEstimate(graphName, configuration); } } diff --git a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensWriteProc.java b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensWriteProc.java index 16537b4b03..8983c5d1e7 100644 --- a/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensWriteProc.java +++ b/proc/path-finding/src/main/java/org/neo4j/gds/paths/sourcetarget/ShortestPathYensWriteProc.java @@ -19,10 +19,6 @@ */ package org.neo4j.gds.paths.sourcetarget; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.core.write.RelationshipStreamExporterBuilder; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.MemoryEstimationExecutor; import org.neo4j.gds.procedures.GraphDataScience; import org.neo4j.gds.results.MemoryEstimateResult; import org.neo4j.gds.results.StandardWriteRelationshipsResult; @@ -34,17 +30,15 @@ import java.util.Map; import java.util.stream.Stream; +import static org.neo4j.gds.ProcedureConstants.ESTIMATE_DESCRIPTION; import static org.neo4j.gds.paths.sourcetarget.SinglePairShortestPathConstants.YENS_DESCRIPTION; import static org.neo4j.procedure.Mode.READ; import static org.neo4j.procedure.Mode.WRITE; -public class ShortestPathYensWriteProc extends BaseProc { +public class ShortestPathYensWriteProc { @Context public GraphDataScience facade; - @Context - public RelationshipStreamExporterBuilder relationshipStreamExporterBuilder; - @Procedure(name = "gds.shortestPath.yens.write", mode = WRITE) @Description(YENS_DESCRIPTION) public Stream write( @@ -60,15 +54,6 @@ public Stream estimate( @Name(value = "graphName") Object graphName, @Name(value = "configuration") Map configuration ) { - return new MemoryEstimationExecutor<>( - new ShortestPathYensWriteSpec(), - executionContext(), - transactionContext() - ).computeEstimate(graphName, configuration); - } - - @Override - public ExecutionContext executionContext() { - return super.executionContext().withRelationshipStreamExporterBuilder(relationshipStreamExporterBuilder); + return facade.pathFinding().singlePairShortestPathYensWriteEstimate(graphName, configuration); } } diff --git a/procedures/facade/src/main/java/org/neo4j/gds/procedures/pathfinding/PathFindingProcedureFacade.java b/procedures/facade/src/main/java/org/neo4j/gds/procedures/pathfinding/PathFindingProcedureFacade.java index 7c5beec87a..b82c7b0830 100644 --- a/procedures/facade/src/main/java/org/neo4j/gds/procedures/pathfinding/PathFindingProcedureFacade.java +++ b/procedures/facade/src/main/java/org/neo4j/gds/procedures/pathfinding/PathFindingProcedureFacade.java @@ -150,6 +150,22 @@ public Stream singlePairShortestPathAStarWrite ); } + public Stream singlePairShortestPathAStarWriteEstimate( + Object graphNameOrConfiguration, + Map algorithmConfiguration + ) { + var result = runEstimation( + algorithmConfiguration, + ShortestPathAStarWriteConfig::of, + configuration -> facade.singlePairShortestPathAStarEstimate( + configuration, + graphNameOrConfiguration + ) + ); + + return Stream.of(result); + } + public Stream singlePairShortestPathDijkstraMutate( String graphName, Map configuration @@ -164,6 +180,22 @@ public Stream singlePairShortestPathDijkstraMutate( ); } + public Stream singlePairShortestPathDijkstraMutateEstimate( + Object graphNameOrConfiguration, + Map algorithmConfiguration + ) { + var result = runEstimation( + algorithmConfiguration, + ShortestPathDijkstraMutateConfig::of, + configuration -> facade.singlePairShortestPathDijkstraEstimate( + configuration, + graphNameOrConfiguration + ) + ); + + return Stream.of(result); + } + public Stream singlePairShortestPathDijkstraStream( String graphName, Map configuration @@ -176,6 +208,22 @@ public Stream singlePairShortestPathDijkstraStream( ); } + public Stream singlePairShortestPathDijkstraStreamEstimate( + Object graphNameOrConfiguration, + Map algorithmConfiguration + ) { + var result = runEstimation( + algorithmConfiguration, + ShortestPathDijkstraStreamConfig::of, + configuration -> facade.singlePairShortestPathDijkstraEstimate( + configuration, + graphNameOrConfiguration + ) + ); + + return Stream.of(result); + } + public Stream singlePairShortestPathDijkstraWrite( String graphName, Map configuration @@ -190,6 +238,22 @@ public Stream singlePairShortestPathDijkstraWr ); } + public Stream singlePairShortestPathDijkstraWriteEstimate( + Object graphNameOrConfiguration, + Map algorithmConfiguration + ) { + var result = runEstimation( + algorithmConfiguration, + ShortestPathDijkstraWriteConfig::of, + configuration -> facade.singlePairShortestPathDijkstraEstimate( + configuration, + graphNameOrConfiguration + ) + ); + + return Stream.of(result); + } + public Stream singlePairShortestPathYensMutate( String graphName, Map configuration @@ -204,6 +268,22 @@ public Stream singlePairShortestPathYensMutate( ); } + public Stream singlePairShortestPathYensMutateEstimate( + Object graphNameOrConfiguration, + Map algorithmConfiguration + ) { + var result = runEstimation( + algorithmConfiguration, + ShortestPathYensMutateConfig::of, + configuration -> facade.singlePairShortestPathYensEstimate( + configuration, + graphNameOrConfiguration + ) + ); + + return Stream.of(result); + } + public Stream singlePairShortestPathYensStream( String graphName, Map configuration @@ -216,6 +296,22 @@ public Stream singlePairShortestPathYensStream( ); } + public Stream singlePairShortestPathYensStreamEstimate( + Object graphNameOrConfiguration, + Map algorithmConfiguration + ) { + var result = runEstimation( + algorithmConfiguration, + ShortestPathYensStreamConfig::of, + configuration -> facade.singlePairShortestPathYensEstimate( + configuration, + graphNameOrConfiguration + ) + ); + + return Stream.of(result); + } + public Stream singlePairShortestPathYensWrite( String graphName, Map configuration @@ -230,6 +326,22 @@ public Stream singlePairShortestPathYensWrite( ); } + public Stream singlePairShortestPathYensWriteEstimate( + Object graphNameOrConfiguration, + Map algorithmConfiguration + ) { + var result = runEstimation( + algorithmConfiguration, + ShortestPathYensWriteConfig::of, + configuration -> facade.singlePairShortestPathYensEstimate( + configuration, + graphNameOrConfiguration + ) + ); + + return Stream.of(result); + } + public Stream singleSourceShortestPathDijkstraMutate( String graphName, Map configuration