From 3b1fb1c57578d23035110573419b1a8dd2ccddbd Mon Sep 17 00:00:00 2001 From: ioannispan Date: Mon, 19 Aug 2024 16:38:31 +0200 Subject: [PATCH] step is not optional following cleanups --- .../algorithms/machinery/AlgorithmProcessingTemplate.java | 2 +- .../machinery/AlgorithmProcessingTemplateConvenience.java | 4 ++-- .../machinery/DefaultAlgorithmProcessingTemplate.java | 8 ++++---- .../machinery/DefaultAlgorithmProcessingTemplateTest.java | 8 ++++---- .../embeddings/GraphSageAlgorithmProcessing.java | 2 +- .../embeddings/Node2VecAlgorithmProcessing.java | 2 +- .../NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java | 6 ++---- .../NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java | 2 +- .../NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java | 6 ++---- 9 files changed, 18 insertions(+), 22 deletions(-) diff --git a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplate.java b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplate.java index d90e7b6f2f..a13222b943 100644 --- a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplate.java +++ b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplate.java @@ -64,7 +64,7 @@ RESULT_TO_CALLER processAlgorithm( LabelForProgressTracking label, Supplier estimationFactory, AlgorithmComputation algorithmComputation, - Optional> mutateOrWriteStep, + MutateOrWriteStep mutateOrWriteStep, ResultBuilder resultBuilder ); diff --git a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplateConvenience.java b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplateConvenience.java index 3266748fb0..fdde85e178 100644 --- a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplateConvenience.java +++ b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmProcessingTemplateConvenience.java @@ -47,7 +47,7 @@ public estimationFactory, AlgorithmComputation algorithmComputation, - Optional> mutateOrWriteStep, + MutateOrWriteStep mutateOrWriteStep, ResultBuilder resultBuilder ) { return algorithmProcessingTemplate.processAlgorithm( @@ -83,7 +83,7 @@ public estimationFactory, AlgorithmComputation algorithmComputation, - Optional> mutateOrWriteStep, + MutateOrWriteStep mutateOrWriteStep, ResultBuilder resultBuilder ) { // as we progress through the steps we gather timings @@ -295,7 +295,7 @@ private RESULT_FROM_ALGORITHM computeWithMetric( * @return null if we are not in mutate or write mode; appropriate metadata otherwise */ Optional mutateOrWriteWithTiming( - Optional> mutateOrWriteStep, + MutateOrWriteStep mutateOrWriteStep, AlgorithmProcessingTimingsBuilder timingsBuilder, Graph graph, GraphStore graphStore, @@ -303,10 +303,10 @@ Optional result, JobId jobId ) { - if (mutateOrWriteStep.isEmpty() || result.isEmpty()) return Optional.empty(); + if (result.isEmpty()) return Optional.empty(); try (ProgressTimer ignored = ProgressTimer.start(timingsBuilder::withMutateOrWriteMillis)) { - return Optional.ofNullable(mutateOrWriteStep.get().execute(graph, graphStore, resultStore, result.get(), jobId)); + return Optional.ofNullable(mutateOrWriteStep.execute(graph, graphStore, resultStore, result.get(), jobId)); } } diff --git a/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java b/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java index 583f4e8097..5748fe35d5 100644 --- a/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java +++ b/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java @@ -202,7 +202,7 @@ public Long execute( KNN, null, computation, - Optional.of(mutateOrWriteStep), + mutateOrWriteStep, resultBuilder ); @@ -244,7 +244,7 @@ RESULT_FROM_ALGORITHM computeWithTiming( @Override Optional mutateOrWriteWithTiming( - Optional> mutateOrWriteStep, + MutateOrWriteStep mutateOrWriteStep, AlgorithmProcessingTimingsBuilder timingsBuilder, Graph graph, GraphStore graphStore, @@ -254,7 +254,7 @@ Optional build( null, null, null, - Optional.of((graph, graphStore, resultStore, unused, jobId) -> 6573L), + (graph, graphStore, resultStore, unused, jobId) -> 6573L, resultBuilder ); diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java index ed2df09865..704c0e04be 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java @@ -52,7 +52,7 @@ public GraphSageAlgorithmProcessing( RESULT process( GraphName graphName, CONFIGURATION configuration, - Optional> mutateOrWriteStep, + MutateOrWriteStep mutateOrWriteStep, ResultBuilder resultBuilder, boolean mutating ) { diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java index b777282597..094bdb8247 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java @@ -52,7 +52,7 @@ public Node2VecAlgorithmProcessing( RESULT process( GraphName graphName, CONFIGURATION configuration, - Optional> mutateOrWriteStep, + MutateOrWriteStep mutateOrWriteStep, ResultBuilder resultBuilder ) { var validationHook = new Node2VecValidationHook(configuration); diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java index 0410bfc9b8..7ccd3e9296 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java @@ -33,8 +33,6 @@ import org.neo4j.gds.embeddings.node2vec.Node2VecMutateConfig; import org.neo4j.gds.embeddings.node2vec.Node2VecResult; -import java.util.Optional; - import static org.neo4j.gds.applications.algorithms.metadata.LabelForProgressTracking.FastRP; import static org.neo4j.gds.applications.algorithms.metadata.LabelForProgressTracking.HashGNN; @@ -90,7 +88,7 @@ public RESULT graphSage( return graphSageAlgorithmProcessing.process( graphName, configuration, - Optional.of(mutateStep), + mutateStep, resultBuilder, true ); @@ -121,6 +119,6 @@ public RESULT node2Vec( ) { var mutateStep = new Node2VecMutateStep(mutateNodeProperty, configuration); - return node2VecAlgorithmProcessing.process(graphName, configuration, Optional.of(mutateStep), resultBuilder); + return node2VecAlgorithmProcessing.process(graphName, configuration, mutateStep, resultBuilder); } } diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java index c3cbfa873f..932a81e578 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java @@ -75,7 +75,7 @@ public RESULT graphSage( GraphSageTrain, () -> estimation.graphSageTrain(configuration), (graph, __) -> algorithms.graphSageTrain(graph, configuration), - Optional.of(writeToDiskStep), + writeToDiskStep, resultBuilder ); } diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java index 14497f71a9..70dfc42340 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java @@ -34,8 +34,6 @@ import org.neo4j.gds.embeddings.node2vec.Node2VecWriteConfig; import org.neo4j.gds.logging.Log; -import java.util.Optional; - import static org.neo4j.gds.applications.algorithms.metadata.LabelForProgressTracking.FastRP; public final class NodeEmbeddingAlgorithmsWriteModeBusinessFacade { @@ -111,7 +109,7 @@ public RESULT graphSage( return graphSageAlgorithmProcessing.process( graphName, configuration, - Optional.of(writeStep), + writeStep, resultBuilder, false ); @@ -124,6 +122,6 @@ public RESULT node2Vec( ) { var writeStep = new Node2VecWriteStep(writeToDatabase, configuration); - return node2VecAlgorithmProcessing.process(graphName, configuration, Optional.of(writeStep), resultBuilder); + return node2VecAlgorithmProcessing.process(graphName, configuration, writeStep, resultBuilder); } }