Skip to content

Commit

Permalink
Merge pull request #9554 from vnickolov/refactor-mutate-stub-construc…
Browse files Browse the repository at this point in the history
…tion

Refactor ProcedureFacades construction
  • Loading branch information
IoannisPanagiotas authored Aug 29, 2024
2 parents 2321136 + 72f1a38 commit c0ca33b
Show file tree
Hide file tree
Showing 49 changed files with 1,033 additions and 876 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
package org.neo4j.gds.procedures.algorithms.centrality.stubs;

import org.neo4j.gds.applications.ApplicationsFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsEstimationModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsMutateModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
import org.neo4j.gds.articulationpoints.ArticulationPointsMutateConfig;
import org.neo4j.gds.mem.MemoryEstimation;
Expand All @@ -33,14 +33,17 @@

public class ArticulationPointsMutateStub implements MutateStub<ArticulationPointsMutateConfig, ArticulationPointsMutateResult> {
private final GenericStub genericStub;
private final ApplicationsFacade applicationsFacade;
private final CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade;
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade;

public ArticulationPointsMutateStub(
GenericStub genericStub,
ApplicationsFacade applicationsFacade
CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade,
CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade
) {
this.genericStub = genericStub;
this.applicationsFacade = applicationsFacade;
this.mutateModeBusinessFacade = mutateModeBusinessFacade;
this.estimationModeBusinessFacade = estimationModeBusinessFacade;
}

@Override
Expand All @@ -54,7 +57,7 @@ public MemoryEstimation getMemoryEstimation(String username, Map<String, Object>
username,
configuration,
ArticulationPointsMutateConfig::of,
(config) -> estimationMode().articulationPoints()
(config) -> estimationModeBusinessFacade.articulationPoints()
);
}

Expand All @@ -64,24 +67,24 @@ public Stream<MemoryEstimateResult> estimate(Object graphName, Map<String, Objec
graphName,
configuration,
ArticulationPointsMutateConfig::of,
(config) -> estimationMode().articulationPoints()
(config) -> estimationModeBusinessFacade.articulationPoints()
);
}

@Override
public Stream<ArticulationPointsMutateResult> execute(String graphNameAsString, Map<String, Object> rawConfiguration) {
public Stream<ArticulationPointsMutateResult> execute(
String graphNameAsString,
Map<String, Object> rawConfiguration
) {
var resultBuilder = new ArticulationPointsResultBuilderForMutateMode();

return genericStub.execute(
graphNameAsString,
rawConfiguration,
ArticulationPointsMutateConfig::of,
applicationsFacade.centrality().mutate()::articulationPoints,
mutateModeBusinessFacade::articulationPoints,
resultBuilder
);
}

private CentralityAlgorithmsEstimationModeBusinessFacade estimationMode() {
return applicationsFacade.centrality().estimate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.neo4j.gds.procedures.algorithms.centrality.stubs;

import org.neo4j.gds.api.ProcedureReturnColumns;
import org.neo4j.gds.applications.ApplicationsFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsEstimationModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsMutateModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
import org.neo4j.gds.closeness.ClosenessCentralityMutateConfig;
import org.neo4j.gds.mem.MemoryEstimation;
Expand All @@ -34,16 +34,19 @@

public class BetaClosenessCentralityMutateStub implements MutateStub<ClosenessCentralityMutateConfig, BetaClosenessCentralityMutateResult> {
private final GenericStub genericStub;
private final ApplicationsFacade applicationsFacade;
private final CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade;
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade;
private final ProcedureReturnColumns procedureReturnColumns;

public BetaClosenessCentralityMutateStub(
GenericStub genericStub,
ApplicationsFacade applicationsFacade,
CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade,
CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade,
ProcedureReturnColumns procedureReturnColumns
) {
this.genericStub = genericStub;
this.applicationsFacade = applicationsFacade;
this.mutateModeBusinessFacade = mutateModeBusinessFacade;
this.estimationModeBusinessFacade = estimationModeBusinessFacade;
this.procedureReturnColumns = procedureReturnColumns;
}

Expand All @@ -58,7 +61,7 @@ public MemoryEstimation getMemoryEstimation(String username, Map<String, Object>
username,
configuration,
ClosenessCentralityMutateConfig::of,
estimationMode()::closenessCentrality
estimationModeBusinessFacade::closenessCentrality
);
}

Expand All @@ -68,7 +71,7 @@ public Stream<MemoryEstimateResult> estimate(Object graphName, Map<String, Objec
graphName,
configuration,
ClosenessCentralityMutateConfig::of,
estimationMode()::closenessCentrality
estimationModeBusinessFacade::closenessCentrality
);
}

Expand All @@ -84,12 +87,9 @@ public Stream<BetaClosenessCentralityMutateResult> execute(
graphNameAsString,
rawConfiguration,
ClosenessCentralityMutateConfig::of,
applicationsFacade.centrality().mutate()::closenessCentrality,
mutateModeBusinessFacade::closenessCentrality,
resultBuilder
);
}

private CentralityAlgorithmsEstimationModeBusinessFacade estimationMode() {
return applicationsFacade.centrality().estimate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.neo4j.gds.procedures.algorithms.centrality.stubs;

import org.neo4j.gds.api.ProcedureReturnColumns;
import org.neo4j.gds.applications.ApplicationsFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsEstimationModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsMutateModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
import org.neo4j.gds.betweenness.BetweennessCentralityMutateConfig;
import org.neo4j.gds.mem.MemoryEstimation;
Expand All @@ -34,16 +34,19 @@

public class BetweennessCentralityMutateStub implements MutateStub<BetweennessCentralityMutateConfig, CentralityMutateResult> {
private final GenericStub genericStub;
private final ApplicationsFacade applicationsFacade;
private final CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade;
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade;
private final ProcedureReturnColumns procedureReturnColumns;

public BetweennessCentralityMutateStub(
GenericStub genericStub,
ApplicationsFacade applicationsFacade,
CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade,
CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade,
ProcedureReturnColumns procedureReturnColumns
) {
this.genericStub = genericStub;
this.applicationsFacade = applicationsFacade;
this.mutateModeBusinessFacade = mutateModeBusinessFacade;
this.estimationModeBusinessFacade = estimationModeBusinessFacade;
this.procedureReturnColumns = procedureReturnColumns;
}

Expand All @@ -58,7 +61,7 @@ public MemoryEstimation getMemoryEstimation(String username, Map<String, Object>
username,
configuration,
BetweennessCentralityMutateConfig::of,
estimationMode()::betweennessCentrality
estimationModeBusinessFacade::betweennessCentrality
);
}

Expand All @@ -68,7 +71,7 @@ public Stream<MemoryEstimateResult> estimate(Object graphName, Map<String, Objec
graphName,
configuration,
BetweennessCentralityMutateConfig::of,
estimationMode()::betweennessCentrality
estimationModeBusinessFacade::betweennessCentrality
);
}

Expand All @@ -81,12 +84,9 @@ public Stream<CentralityMutateResult> execute(String graphNameAsString, Map<Stri
graphNameAsString,
rawConfiguration,
BetweennessCentralityMutateConfig::of,
applicationsFacade.centrality().mutate()::betweennessCentrality,
mutateModeBusinessFacade::betweennessCentrality,
resultBuilder
);
}

private CentralityAlgorithmsEstimationModeBusinessFacade estimationMode() {
return applicationsFacade.centrality().estimate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
package org.neo4j.gds.procedures.algorithms.centrality.stubs;

import org.neo4j.gds.applications.ApplicationsFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsEstimationModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsMutateModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
import org.neo4j.gds.influenceMaximization.InfluenceMaximizationMutateConfig;
import org.neo4j.gds.mem.MemoryEstimation;
Expand All @@ -33,14 +33,17 @@

public class CelfMutateStub implements MutateStub<InfluenceMaximizationMutateConfig, CELFMutateResult> {
private final GenericStub genericStub;
private final ApplicationsFacade applicationsFacade;
private final CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade;
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade;

public CelfMutateStub(
GenericStub genericStub,
ApplicationsFacade applicationsFacade
CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade,
CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade
) {
this.genericStub = genericStub;
this.applicationsFacade = applicationsFacade;
this.mutateModeBusinessFacade = mutateModeBusinessFacade;
this.estimationModeBusinessFacade = estimationModeBusinessFacade;
}

@Override
Expand All @@ -54,7 +57,7 @@ public MemoryEstimation getMemoryEstimation(String username, Map<String, Object>
username,
configuration,
InfluenceMaximizationMutateConfig::of,
estimationMode()::celf
estimationModeBusinessFacade::celf
);
}

Expand All @@ -64,7 +67,7 @@ public Stream<MemoryEstimateResult> estimate(Object graphName, Map<String, Objec
graphName,
configuration,
InfluenceMaximizationMutateConfig::of,
estimationMode()::celf
estimationModeBusinessFacade::celf
);
}

Expand All @@ -76,12 +79,9 @@ public Stream<CELFMutateResult> execute(String graphNameAsString, Map<String, Ob
graphNameAsString,
rawConfiguration,
InfluenceMaximizationMutateConfig::of,
applicationsFacade.centrality().mutate()::celf,
mutateModeBusinessFacade::celf,
resultBuilder
);
}

private CentralityAlgorithmsEstimationModeBusinessFacade estimationMode() {
return applicationsFacade.centrality().estimate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.neo4j.gds.procedures.algorithms.centrality.stubs;

import org.neo4j.gds.api.ProcedureReturnColumns;
import org.neo4j.gds.applications.ApplicationsFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsEstimationModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsMutateModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
import org.neo4j.gds.closeness.ClosenessCentralityMutateConfig;
import org.neo4j.gds.mem.MemoryEstimation;
Expand All @@ -34,16 +34,19 @@

public class ClosenessCentralityMutateStub implements MutateStub<ClosenessCentralityMutateConfig, CentralityMutateResult> {
private final GenericStub genericStub;
private final ApplicationsFacade applicationsFacade;
private final CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade;
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade;
private final ProcedureReturnColumns procedureReturnColumns;

public ClosenessCentralityMutateStub(
GenericStub genericStub,
ApplicationsFacade applicationsFacade,
CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade,
CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade,
ProcedureReturnColumns procedureReturnColumns
) {
this.genericStub = genericStub;
this.applicationsFacade = applicationsFacade;
this.mutateModeBusinessFacade = mutateModeBusinessFacade;
this.estimationModeBusinessFacade = estimationModeBusinessFacade;
this.procedureReturnColumns = procedureReturnColumns;
}

Expand All @@ -58,7 +61,7 @@ public MemoryEstimation getMemoryEstimation(String username, Map<String, Object>
username,
configuration,
ClosenessCentralityMutateConfig::of,
estimationMode()::closenessCentrality
estimationModeBusinessFacade::closenessCentrality
);
}

Expand All @@ -68,7 +71,7 @@ public Stream<MemoryEstimateResult> estimate(Object graphName, Map<String, Objec
graphName,
configuration,
ClosenessCentralityMutateConfig::of,
estimationMode()::closenessCentrality
estimationModeBusinessFacade::closenessCentrality
);
}

Expand All @@ -81,12 +84,9 @@ public Stream<CentralityMutateResult> execute(String graphNameAsString, Map<Stri
graphNameAsString,
rawConfiguration,
ClosenessCentralityMutateConfig::of,
applicationsFacade.centrality().mutate()::closenessCentrality,
mutateModeBusinessFacade::closenessCentrality,
resultBuilder
);
}

private CentralityAlgorithmsEstimationModeBusinessFacade estimationMode() {
return applicationsFacade.centrality().estimate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.neo4j.gds.procedures.algorithms.centrality.stubs;

import org.neo4j.gds.api.ProcedureReturnColumns;
import org.neo4j.gds.applications.ApplicationsFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsEstimationModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithmsMutateModeBusinessFacade;
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
import org.neo4j.gds.degree.DegreeCentralityMutateConfig;
import org.neo4j.gds.mem.MemoryEstimation;
Expand All @@ -34,16 +34,19 @@

public class DegreeCentralityMutateStub implements MutateStub<DegreeCentralityMutateConfig, CentralityMutateResult> {
private final GenericStub genericStub;
private final ApplicationsFacade applicationsFacade;
private final CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade;
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade;
private final ProcedureReturnColumns procedureReturnColumns;

public DegreeCentralityMutateStub(
GenericStub genericStub,
ApplicationsFacade applicationsFacade,
CentralityAlgorithmsMutateModeBusinessFacade mutateModeBusinessFacade,
CentralityAlgorithmsEstimationModeBusinessFacade estimationModeBusinessFacade,
ProcedureReturnColumns procedureReturnColumns
) {
this.genericStub = genericStub;
this.applicationsFacade = applicationsFacade;
this.mutateModeBusinessFacade = mutateModeBusinessFacade;
this.estimationModeBusinessFacade = estimationModeBusinessFacade;
this.procedureReturnColumns = procedureReturnColumns;
}

Expand All @@ -58,7 +61,7 @@ public MemoryEstimation getMemoryEstimation(String username, Map<String, Object>
username,
configuration,
DegreeCentralityMutateConfig::of,
estimationMode()::degreeCentrality
estimationModeBusinessFacade::degreeCentrality
);
}

Expand All @@ -68,7 +71,7 @@ public Stream<MemoryEstimateResult> estimate(Object graphName, Map<String, Objec
graphName,
configuration,
DegreeCentralityMutateConfig::of,
estimationMode()::degreeCentrality
estimationModeBusinessFacade::degreeCentrality
);
}

Expand All @@ -81,12 +84,9 @@ public Stream<CentralityMutateResult> execute(String graphNameAsString, Map<Stri
graphNameAsString,
rawConfiguration,
DegreeCentralityMutateConfig::of,
applicationsFacade.centrality().mutate()::degreeCentrality,
mutateModeBusinessFacade::degreeCentrality,
resultBuilder
);
}

private CentralityAlgorithmsEstimationModeBusinessFacade estimationMode() {
return applicationsFacade.centrality().estimate();
}
}
Loading

0 comments on commit c0ca33b

Please sign in to comment.