From ad57a48369db9a88a8cba51af96c2514ab31b6ff Mon Sep 17 00:00:00 2001 From: Lasse Westh-Nielsen Date: Wed, 15 Nov 2023 17:45:46 +0100 Subject: [PATCH] roll out request scoped dependencies parameter object through layers for WCC --- .../community/CommunityAlgorithmsFacade.java | 13 ++--- ...mmunityAlgorithmsMutateBusinessFacade.java | 7 ++- ...ommunityAlgorithmsStatsBusinessFacade.java | 7 ++- ...mmunityAlgorithmsStreamBusinessFacade.java | 14 ++---- ...ommunityAlgorithmsWriteBusinessFacade.java | 7 ++- ...ityAlgorithmsStreamBusinessFacadeTest.java | 11 +++-- .../k1coloring/K1ColoringStreamProcTest.java | 9 ++-- .../LabelPropagationMutateProcTest.java | 32 ++++++++----- .../ModularityOptimizationMutateProcTest.java | 9 ++-- .../org/neo4j/gds/wcc/WccMutateProcTest.java | 32 ++++++++----- .../org/neo4j/gds/wcc/WccStatsProcTest.java | 8 ++-- .../org/neo4j/gds/wcc/WccWriteProcTest.java | 8 ++-- .../community/CommunityProcedureFacade.java | 47 +++++++++++-------- .../CommunityProcedureProvider.java | 11 +++-- 14 files changed, 123 insertions(+), 92 deletions(-) diff --git a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsFacade.java b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsFacade.java index 57871287ad..7000496e4b 100644 --- a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsFacade.java +++ b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsFacade.java @@ -20,6 +20,7 @@ package org.neo4j.gds.algorithms.community; import org.neo4j.gds.algorithms.AlgorithmComputationResult; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.runner.AlgorithmRunner; import org.neo4j.gds.api.DatabaseId; import org.neo4j.gds.api.User; @@ -80,20 +81,16 @@ public CommunityAlgorithmsFacade( } AlgorithmComputationResult wcc( + RequestScopedDependencies requestScopedDependencies, String graphName, - WccBaseConfig config, - User user, - DatabaseId databaseId, - TerminationFlag terminationFlag + WccBaseConfig config ) { return algorithmRunner.run( + requestScopedDependencies, graphName, config, config.relationshipWeightProperty(), - new WccAlgorithmFactory<>(), - user, - databaseId, - terminationFlag + new WccAlgorithmFactory<>() ); } diff --git a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsMutateBusinessFacade.java b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsMutateBusinessFacade.java index aaa2570a73..3e3cb993d5 100644 --- a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsMutateBusinessFacade.java +++ b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsMutateBusinessFacade.java @@ -21,6 +21,7 @@ import org.neo4j.gds.algorithms.AlgorithmComputationResult; import org.neo4j.gds.algorithms.NodePropertyMutateResult; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.specificfields.ApproxMaxKCutSpecificFields; import org.neo4j.gds.algorithms.community.specificfields.CommunityStatisticsSpecificFields; import org.neo4j.gds.algorithms.community.specificfields.K1ColoringSpecificFields; @@ -80,16 +81,14 @@ public CommunityAlgorithmsMutateBusinessFacade( } public NodePropertyMutateResult wcc( + RequestScopedDependencies requestScopedDependencies, String graphName, WccMutateConfig configuration, - User user, - DatabaseId databaseId, - TerminationFlag terminationFlag, StatisticsComputationInstructions statisticsComputationInstructions ) { // 1. Run the algorithm and time the execution var intermediateResult = runWithTiming( - () -> communityAlgorithmsFacade.wcc(graphName, configuration, user, databaseId, terminationFlag) + () -> communityAlgorithmsFacade.wcc(requestScopedDependencies, graphName, configuration) ); var algorithmResult = intermediateResult.algorithmResult; diff --git a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStatsBusinessFacade.java b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStatsBusinessFacade.java index e5c0716d66..96189ce0e7 100644 --- a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStatsBusinessFacade.java +++ b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStatsBusinessFacade.java @@ -20,6 +20,7 @@ package org.neo4j.gds.algorithms.community; import org.neo4j.gds.algorithms.AlgorithmComputationResult; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.specificfields.CommunityStatisticsSpecificFields; import org.neo4j.gds.algorithms.community.specificfields.K1ColoringSpecificFields; import org.neo4j.gds.algorithms.community.specificfields.KCoreSpecificFields; @@ -68,16 +69,14 @@ public CommunityAlgorithmsStatsBusinessFacade(CommunityAlgorithmsFacade communit } public StatsResult wcc( + RequestScopedDependencies requestScopedDependencies, String graphName, WccStatsConfig configuration, - User user, - DatabaseId databaseId, - TerminationFlag terminationFlag, StatisticsComputationInstructions statisticsComputationInstructions ) { // 1. Run the algorithm and time the execution var intermediateResult = AlgorithmRunner.runWithTiming( - () -> communityAlgorithmsFacade.wcc(graphName, configuration, user, databaseId, terminationFlag) + () -> communityAlgorithmsFacade.wcc(requestScopedDependencies, graphName, configuration) ); var algorithmResult = intermediateResult.algorithmResult; diff --git a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacade.java b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacade.java index 4e30bba37b..a799d0acd4 100644 --- a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacade.java +++ b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacade.java @@ -20,6 +20,7 @@ package org.neo4j.gds.algorithms.community; import org.neo4j.gds.algorithms.AlgorithmComputationResult; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.StreamComputationResult; import org.neo4j.gds.api.DatabaseId; import org.neo4j.gds.api.User; @@ -61,19 +62,14 @@ public CommunityAlgorithmsStreamBusinessFacade(CommunityAlgorithmsFacade communi } public StreamComputationResult wcc( + RequestScopedDependencies requestScopedDependencies, String graphName, - WccBaseConfig config, - User user, - DatabaseId databaseId, - TerminationFlag terminationFlag + WccBaseConfig config ) { - var result = this.communityAlgorithmsFacade.wcc( + requestScopedDependencies, graphName, - config, - user, - databaseId, - terminationFlag + config ); return createStreamComputationResult(result); diff --git a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsWriteBusinessFacade.java b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsWriteBusinessFacade.java index d3e427e332..2a817449c1 100644 --- a/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsWriteBusinessFacade.java +++ b/algo/src/main/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsWriteBusinessFacade.java @@ -21,6 +21,7 @@ import org.neo4j.gds.algorithms.AlgorithmComputationResult; import org.neo4j.gds.algorithms.NodePropertyWriteResult; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.specificfields.AlphaSccSpecificFields; import org.neo4j.gds.algorithms.community.specificfields.CommunityStatisticsSpecificFields; import org.neo4j.gds.algorithms.community.specificfields.K1ColoringSpecificFields; @@ -83,17 +84,15 @@ public CommunityAlgorithmsWriteBusinessFacade( } public NodePropertyWriteResult wcc( + RequestScopedDependencies requestScopedDependencies, String graphName, WccWriteConfig configuration, - User user, - DatabaseId databaseId, TerminationFlag terminationFlag, StatisticsComputationInstructions statisticsComputationInstructions ) { - // 1. Run the algorithm and time the execution var intermediateResult = AlgorithmRunner.runWithTiming( - () -> communityAlgorithmsFacade.wcc(graphName, configuration, user, databaseId, terminationFlag) + () -> communityAlgorithmsFacade.wcc(requestScopedDependencies, graphName, configuration) ); var algorithmResult = intermediateResult.algorithmResult; diff --git a/algo/src/test/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacadeTest.java b/algo/src/test/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacadeTest.java index 397adb654f..3a3ca7e141 100644 --- a/algo/src/test/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacadeTest.java +++ b/algo/src/test/java/org/neo4j/gds/algorithms/community/CommunityAlgorithmsStreamBusinessFacadeTest.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.runner.AlgorithmRunner; import org.neo4j.gds.api.Graph; import org.neo4j.gds.api.GraphStore; @@ -110,11 +111,9 @@ void wcc() { // when var wccComputationResult = algorithmsBusinessFacade.wcc( + RequestScopedDependencies.builder().with(TerminationFlag.RUNNING_TRUE).build(), "meh", - config, - null, - null, - TerminationFlag.RUNNING_TRUE + config ); //then @@ -149,7 +148,9 @@ void wccOnEmptyGraph() { ); // when - var wccComputationResult = algorithmsBusinessFacade.wcc("meh", mock(WccBaseConfig.class), null, null, null); + var wccComputationResult = algorithmsBusinessFacade.wcc( + RequestScopedDependencies.builder().build(), "meh", mock(WccBaseConfig.class) + ); //then assertThat(wccComputationResult.result()).isEmpty(); diff --git a/proc/community/src/test/java/org/neo4j/gds/k1coloring/K1ColoringStreamProcTest.java b/proc/community/src/test/java/org/neo4j/gds/k1coloring/K1ColoringStreamProcTest.java index 7429d5b9ac..6110a879c2 100644 --- a/proc/community/src/test/java/org/neo4j/gds/k1coloring/K1ColoringStreamProcTest.java +++ b/proc/community/src/test/java/org/neo4j/gds/k1coloring/K1ColoringStreamProcTest.java @@ -33,6 +33,7 @@ import org.neo4j.gds.Orientation; import org.neo4j.gds.TestProcedureRunner; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsStreamBusinessFacade; import org.neo4j.gds.algorithms.runner.AlgorithmRunner; @@ -213,10 +214,12 @@ void shouldRegisterTaskWithCorrectJobId() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, mock(AlgorithmMetaDataSetter.class), - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, null, null, null, diff --git a/proc/community/src/test/java/org/neo4j/gds/labelpropagation/LabelPropagationMutateProcTest.java b/proc/community/src/test/java/org/neo4j/gds/labelpropagation/LabelPropagationMutateProcTest.java index f7c40338dd..32676e7a1c 100644 --- a/proc/community/src/test/java/org/neo4j/gds/labelpropagation/LabelPropagationMutateProcTest.java +++ b/proc/community/src/test/java/org/neo4j/gds/labelpropagation/LabelPropagationMutateProcTest.java @@ -43,6 +43,7 @@ import org.neo4j.gds.TestProcedureRunner; import org.neo4j.gds.TestSupport; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsMutateBusinessFacade; import org.neo4j.gds.algorithms.mutateservices.MutateNodePropertyService; @@ -337,10 +338,12 @@ void testWriteBackGraphMutationOnFilteredGraph() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, null, algorithmsMutateBusinessFacade, null, @@ -463,10 +466,12 @@ void testMutateFailsOnExistingToken() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, null, algorithmsMutateBusinessFacade, null, @@ -544,11 +549,12 @@ void testRunOnEmptyGraph() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, null, - null, algorithmsMutateBusinessFacade, null, null, @@ -628,10 +634,12 @@ private GraphStore runMutation(String graphName, Map config) { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, null, algorithmsMutateBusinessFacade, null, diff --git a/proc/community/src/test/java/org/neo4j/gds/modularityoptimization/ModularityOptimizationMutateProcTest.java b/proc/community/src/test/java/org/neo4j/gds/modularityoptimization/ModularityOptimizationMutateProcTest.java index 47738c0e21..f7b89d8b23 100644 --- a/proc/community/src/test/java/org/neo4j/gds/modularityoptimization/ModularityOptimizationMutateProcTest.java +++ b/proc/community/src/test/java/org/neo4j/gds/modularityoptimization/ModularityOptimizationMutateProcTest.java @@ -43,6 +43,7 @@ import org.neo4j.gds.TestProcedureRunner; import org.neo4j.gds.TestSupport; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsEstimateBusinessFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsMutateBusinessFacade; @@ -586,10 +587,12 @@ private GraphDataScience createFacade() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, mock(CommunityAlgorithmsEstimateBusinessFacade.class), algorithmsMutateBusinessFacade, mock(CommunityAlgorithmsStatsBusinessFacade.class), diff --git a/proc/community/src/test/java/org/neo4j/gds/wcc/WccMutateProcTest.java b/proc/community/src/test/java/org/neo4j/gds/wcc/WccMutateProcTest.java index ca9e6c3a44..dccaa36345 100644 --- a/proc/community/src/test/java/org/neo4j/gds/wcc/WccMutateProcTest.java +++ b/proc/community/src/test/java/org/neo4j/gds/wcc/WccMutateProcTest.java @@ -40,6 +40,7 @@ import org.neo4j.gds.TestProcedureRunner; import org.neo4j.gds.TestSupport; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsMutateBusinessFacade; import org.neo4j.gds.algorithms.mutateservices.MutateNodePropertyService; @@ -367,10 +368,12 @@ void testWriteBackGraphMutationOnFilteredGraph() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, null, algorithmsMutateBusinessFacade, null, @@ -497,10 +500,12 @@ void testMutateFailsOnExistingToken() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, null, algorithmsBusinessFacade, null, @@ -576,11 +581,12 @@ void testRunOnEmptyGraph() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, null, - null, algorithmsBusinessFacade, null, null, @@ -661,10 +667,12 @@ private GraphStore runMutation(String graphName, Map additionalC new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(TerminationFlag.RUNNING_TRUE) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, - TerminationFlag.RUNNING_TRUE, null, algorithmsBusinessFacade, null, diff --git a/proc/community/src/test/java/org/neo4j/gds/wcc/WccStatsProcTest.java b/proc/community/src/test/java/org/neo4j/gds/wcc/WccStatsProcTest.java index 05ed57fcff..6846b9ba3b 100644 --- a/proc/community/src/test/java/org/neo4j/gds/wcc/WccStatsProcTest.java +++ b/proc/community/src/test/java/org/neo4j/gds/wcc/WccStatsProcTest.java @@ -36,6 +36,7 @@ import org.neo4j.gds.TestProcedureRunner; import org.neo4j.gds.TestSupport; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsStatsBusinessFacade; import org.neo4j.gds.algorithms.runner.AlgorithmRunner; @@ -289,12 +290,13 @@ private GraphDataScience createFacade() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, null, null, - null, statsBusinessFacade, null, null diff --git a/proc/community/src/test/java/org/neo4j/gds/wcc/WccWriteProcTest.java b/proc/community/src/test/java/org/neo4j/gds/wcc/WccWriteProcTest.java index b910bad7cd..dbc6648302 100644 --- a/proc/community/src/test/java/org/neo4j/gds/wcc/WccWriteProcTest.java +++ b/proc/community/src/test/java/org/neo4j/gds/wcc/WccWriteProcTest.java @@ -39,6 +39,7 @@ import org.neo4j.gds.TestProcedureRunner; import org.neo4j.gds.TestSupport; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsWriteBusinessFacade; import org.neo4j.gds.algorithms.runner.AlgorithmRunner; @@ -497,14 +498,15 @@ void testRunOnEmptyGraph() { new CommunityProcedureFacade( ConfigurationParser.EMPTY, null, - new User(getUsername(), false), - DatabaseId.of(db.databaseName()), + RequestScopedDependencies.builder() + .with(DatabaseId.of(db.databaseName())) + .with(new User(getUsername(), false)) + .build(), ProcedureReturnColumns.EMPTY, null, null, null, null, - null, algorithmsBusinessFacade ), null diff --git a/procedures/facade/src/main/java/org/neo4j/gds/procedures/community/CommunityProcedureFacade.java b/procedures/facade/src/main/java/org/neo4j/gds/procedures/community/CommunityProcedureFacade.java index 987401cd91..3cdb30664c 100644 --- a/procedures/facade/src/main/java/org/neo4j/gds/procedures/community/CommunityProcedureFacade.java +++ b/procedures/facade/src/main/java/org/neo4j/gds/procedures/community/CommunityProcedureFacade.java @@ -19,6 +19,7 @@ */ package org.neo4j.gds.procedures.community; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsEstimateBusinessFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsMutateBusinessFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsStatsBusinessFacade; @@ -142,9 +143,25 @@ public class CommunityProcedureFacade { // services private final ConfigurationParser configurationParser; private final AlgorithmMetaDataSetter algorithmMetaDataSetter; + private final RequestScopedDependencies requestScopedDependencies; + + /** + * @deprecated Strangle. + */ + @Deprecated private final User user; + + /** + * @deprecated Strangle. + */ + @Deprecated private final DatabaseId databaseId; private final ProcedureReturnColumns procedureReturnColumns; + + /** + * @deprecated Strangle. + */ + @Deprecated private final TerminationFlag terminationFlag; // business logic @@ -154,14 +171,11 @@ public class CommunityProcedureFacade { private final CommunityAlgorithmsStreamBusinessFacade streamBusinessFacade; private final CommunityAlgorithmsWriteBusinessFacade writeBusinessFacade; - public CommunityProcedureFacade( ConfigurationParser configurationParser, AlgorithmMetaDataSetter algorithmMetaDataSetter, - User user, - DatabaseId databaseId, + RequestScopedDependencies requestScopedDependencies, ProcedureReturnColumns procedureReturnColumns, - TerminationFlag terminationFlag, CommunityAlgorithmsEstimateBusinessFacade estimateBusinessFacade, CommunityAlgorithmsMutateBusinessFacade mutateBusinessFacade, CommunityAlgorithmsStatsBusinessFacade statsBusinessFacade, @@ -170,15 +184,17 @@ public CommunityProcedureFacade( ) { this.configurationParser = configurationParser; this.algorithmMetaDataSetter = algorithmMetaDataSetter; - this.databaseId = databaseId; this.procedureReturnColumns = procedureReturnColumns; - this.user = user; - this.terminationFlag = terminationFlag; this.estimateBusinessFacade = estimateBusinessFacade; this.mutateBusinessFacade = mutateBusinessFacade; this.statsBusinessFacade = statsBusinessFacade; this.streamBusinessFacade = streamBusinessFacade; this.writeBusinessFacade = writeBusinessFacade; + this.requestScopedDependencies = requestScopedDependencies; + + this.databaseId = requestScopedDependencies.getDatabaseId(); + this.terminationFlag = requestScopedDependencies.getTerminationFlag(); + this.user = requestScopedDependencies.getUser(); } // WCC @@ -190,11 +206,9 @@ public Stream wccStream( var streamConfig = createStreamConfig(configuration, WccStreamConfig::of); var computationResult = streamBusinessFacade.wcc( + requestScopedDependencies, graphName, - streamConfig, - user, - databaseId, - terminationFlag + streamConfig ); return WccComputationResultTransformer.toStreamResult(computationResult, streamConfig); @@ -207,11 +221,9 @@ public Stream wccMutate( var config = createConfig(configuration, WccMutateConfig::of); var computationResult = mutateBusinessFacade.wcc( + requestScopedDependencies, graphName, config, - user, - databaseId, - terminationFlag, ProcedureStatisticsComputationInstructions.forComponents(procedureReturnColumns) ); @@ -225,11 +237,9 @@ public Stream wccStats( var config = createConfig(configuration, WccStatsConfig::of); var computationResult = statsBusinessFacade.wcc( + requestScopedDependencies, graphName, config, - user, - databaseId, - terminationFlag, ProcedureStatisticsComputationInstructions.forComponents(procedureReturnColumns) ); @@ -243,10 +253,9 @@ public Stream wccWrite( var writeConfig = createConfig(configuration, WccWriteConfig::of); var computationResult = writeBusinessFacade.wcc( + requestScopedDependencies, graphName, writeConfig, - user, - databaseId, terminationFlag, ProcedureStatisticsComputationInstructions.forComponents(procedureReturnColumns) ); diff --git a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/CommunityProcedureProvider.java b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/CommunityProcedureProvider.java index 455db5d39b..f7fca5f1c2 100644 --- a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/CommunityProcedureProvider.java +++ b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/CommunityProcedureProvider.java @@ -21,6 +21,7 @@ import org.neo4j.gds.ProcedureCallContextReturnColumns; import org.neo4j.gds.algorithms.AlgorithmMemoryValidationService; +import org.neo4j.gds.algorithms.RequestScopedDependencies; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsEstimateBusinessFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsFacade; import org.neo4j.gds.algorithms.community.CommunityAlgorithmsMutateBusinessFacade; @@ -173,14 +174,18 @@ public CommunityProcedureFacade createCommunityProcedureFacade(Context context) DefaultsConfiguration.Instance, LimitsConfiguration.Instance ); + var requestScopedDependencies = RequestScopedDependencies.builder() + .with(databaseId) + .with(terminationFlag) + .with(user) + .build(); + // procedure facade return new CommunityProcedureFacade( configurationParser, algorithmMetaDataSetter, - user, - databaseId, + requestScopedDependencies, returnColumns, - terminationFlag, estimateBusinessFacade, mutateBusinessFacade, statsBusinessFacade,