Skip to content

Commit

Permalink
step is not optional following cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannisPanagiotas committed Aug 19, 2024
1 parent bcc5a4b commit 3b1fb1c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ RESULT_TO_CALLER processAlgorithm(
LabelForProgressTracking label,
Supplier<MemoryEstimation> estimationFactory,
AlgorithmComputation<RESULT_FROM_ALGORITHM> algorithmComputation,
Optional<MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA>> mutateOrWriteStep,
MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> mutateOrWriteStep,
ResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER, MUTATE_OR_WRITE_METADATA> resultBuilder
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public <CONFIGURATION extends AlgoBaseConfig, RESULT_TO_CALLER, RESULT_FROM_ALGO
LabelForProgressTracking label,
Supplier<MemoryEstimation> estimationFactory,
AlgorithmComputation<RESULT_FROM_ALGORITHM> algorithmComputation,
Optional<MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA>> mutateOrWriteStep,
MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> mutateOrWriteStep,
ResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER, MUTATE_OR_WRITE_METADATA> resultBuilder
) {
return algorithmProcessingTemplate.processAlgorithm(
Expand Down Expand Up @@ -83,7 +83,7 @@ public <CONFIGURATION extends AlgoBaseConfig, RESULT_TO_CALLER, RESULT_FROM_ALGO
label,
estimationFactory,
algorithmComputation,
Optional.of(mutateStep),
mutateStep,
resultBuilder
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public <CONFIGURATION extends AlgoBaseConfig, RESULT_TO_CALLER, RESULT_FROM_ALGO
LabelForProgressTracking label,
Supplier<MemoryEstimation> estimationFactory,
AlgorithmComputation<RESULT_FROM_ALGORITHM> algorithmComputation,
Optional<MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA>> mutateOrWriteStep,
MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> mutateOrWriteStep,
ResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER, MUTATE_OR_WRITE_METADATA> resultBuilder
) {
// as we progress through the steps we gather timings
Expand Down Expand Up @@ -295,18 +295,18 @@ private <RESULT_FROM_ALGORITHM> RESULT_FROM_ALGORITHM computeWithMetric(
* @return null if we are not in mutate or write mode; appropriate metadata otherwise
*/
<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> Optional<MUTATE_OR_WRITE_METADATA> mutateOrWriteWithTiming(
Optional<MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA>> mutateOrWriteStep,
MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> mutateOrWriteStep,
AlgorithmProcessingTimingsBuilder timingsBuilder,
Graph graph,
GraphStore graphStore,
ResultStore resultStore,
Optional<RESULT_FROM_ALGORITHM> 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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public Long execute(
KNN,
null,
computation,
Optional.of(mutateOrWriteStep),
mutateOrWriteStep,
resultBuilder
);

Expand Down Expand Up @@ -244,7 +244,7 @@ <RESULT_FROM_ALGORITHM> RESULT_FROM_ALGORITHM computeWithTiming(

@Override
<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> Optional<MUTATE_OR_WRITE_METADATA> mutateOrWriteWithTiming(
Optional<MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA>> mutateOrWriteStep,
MutateOrWriteStep<RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> mutateOrWriteStep,
AlgorithmProcessingTimingsBuilder timingsBuilder,
Graph graph,
GraphStore graphStore,
Expand All @@ -254,7 +254,7 @@ <RESULT_FROM_ALGORITHM, MUTATE_OR_WRITE_METADATA> Optional<MUTATE_OR_WRITE_METAD
) {
timingsBuilder.withMutateOrWriteMillis(87);
return Optional.of(
mutateOrWriteStep.orElseThrow().execute(
mutateOrWriteStep.execute(
graph,
graphStore,
resultStore,
Expand Down Expand Up @@ -292,7 +292,7 @@ public Map<String, Long> build(
null,
null,
null,
Optional.of((graph, graphStore, resultStore, unused, jobId) -> 6573L),
(graph, graphStore, resultStore, unused, jobId) -> 6573L,
resultBuilder
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public GraphSageAlgorithmProcessing(
<CONFIGURATION extends GraphSageBaseConfig, RESULT, MUTATE_OR_WRITE_METADATA> RESULT process(
GraphName graphName,
CONFIGURATION configuration,
Optional<MutateOrWriteStep<GraphSageResult, MUTATE_OR_WRITE_METADATA>> mutateOrWriteStep,
MutateOrWriteStep<GraphSageResult, MUTATE_OR_WRITE_METADATA> mutateOrWriteStep,
ResultBuilder<CONFIGURATION, GraphSageResult, RESULT, MUTATE_OR_WRITE_METADATA> resultBuilder,
boolean mutating
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Node2VecAlgorithmProcessing(
<CONFIGURATION extends Node2VecBaseConfig, RESULT, MUTATE_OR_WRITE_METADATA> RESULT process(
GraphName graphName,
CONFIGURATION configuration,
Optional<MutateOrWriteStep<Node2VecResult, MUTATE_OR_WRITE_METADATA>> mutateOrWriteStep,
MutateOrWriteStep<Node2VecResult, MUTATE_OR_WRITE_METADATA> mutateOrWriteStep,
ResultBuilder<CONFIGURATION, Node2VecResult, RESULT, MUTATE_OR_WRITE_METADATA> resultBuilder
) {
var validationHook = new Node2VecValidationHook(configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -90,7 +88,7 @@ public <RESULT> RESULT graphSage(
return graphSageAlgorithmProcessing.process(
graphName,
configuration,
Optional.of(mutateStep),
mutateStep,
resultBuilder,
true
);
Expand Down Expand Up @@ -121,6 +119,6 @@ public <RESULT> RESULT node2Vec(
) {
var mutateStep = new Node2VecMutateStep(mutateNodeProperty, configuration);

return node2VecAlgorithmProcessing.process(graphName, configuration, Optional.of(mutateStep), resultBuilder);
return node2VecAlgorithmProcessing.process(graphName, configuration, mutateStep, resultBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public <RESULT> RESULT graphSage(
GraphSageTrain,
() -> estimation.graphSageTrain(configuration),
(graph, __) -> algorithms.graphSageTrain(graph, configuration),
Optional.of(writeToDiskStep),
writeToDiskStep,
resultBuilder
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -111,7 +109,7 @@ public <RESULT> RESULT graphSage(
return graphSageAlgorithmProcessing.process(
graphName,
configuration,
Optional.of(writeStep),
writeStep,
resultBuilder,
false
);
Expand All @@ -124,6 +122,6 @@ public <RESULT> RESULT node2Vec(
) {
var writeStep = new Node2VecWriteStep(writeToDatabase, configuration);

return node2VecAlgorithmProcessing.process(graphName, configuration, Optional.of(writeStep), resultBuilder);
return node2VecAlgorithmProcessing.process(graphName, configuration, writeStep, resultBuilder);
}
}

0 comments on commit 3b1fb1c

Please sign in to comment.