From d4771e2c43771d43e507445c38bf572aa79c711c Mon Sep 17 00:00:00 2001 From: Lasse Westh-Nielsen Date: Fri, 16 Aug 2024 16:01:06 +0200 Subject: [PATCH] first pass alphabetising/ categorising --- .../OpenGraphDataScienceExtension.java | 24 +++-- ...> GraphDataScienceProceduresProvider.java} | 78 ++++++++-------- ...DataScienceProceduresProviderFactory.java} | 88 +++++++------------ ...OpenGraphDataScienceExtensionBuilder.java} | 43 +++++---- 4 files changed, 103 insertions(+), 130 deletions(-) rename procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/{GraphDataScienceProvider.java => GraphDataScienceProceduresProvider.java} (96%) rename procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/{GraphDataScienceProviderFactory.java => GraphDataScienceProceduresProviderFactory.java} (81%) rename procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/{GraphDataScienceExtensionBuilder.java => OpenGraphDataScienceExtensionBuilder.java} (91%) diff --git a/procedures/extension/src/main/java/org/neo4j/gds/extension/OpenGraphDataScienceExtension.java b/procedures/extension/src/main/java/org/neo4j/gds/extension/OpenGraphDataScienceExtension.java index 9a74479ea1..ae2890a7cd 100644 --- a/procedures/extension/src/main/java/org/neo4j/gds/extension/OpenGraphDataScienceExtension.java +++ b/procedures/extension/src/main/java/org/neo4j/gds/extension/OpenGraphDataScienceExtension.java @@ -26,7 +26,7 @@ import org.neo4j.gds.metrics.MetricsFacade; import org.neo4j.gds.procedures.ExporterBuildersProviderService; import org.neo4j.gds.procedures.integration.ExportLocation; -import org.neo4j.gds.procedures.integration.GraphDataScienceExtensionBuilder; +import org.neo4j.gds.procedures.integration.OpenGraphDataScienceExtensionBuilder; import org.neo4j.gds.procedures.integration.LogAccessor; import org.neo4j.kernel.api.procedure.GlobalProcedures; import org.neo4j.kernel.extension.ExtensionFactory; @@ -51,30 +51,28 @@ public OpenGraphDataScienceExtension() { @Override public Lifecycle newInstance(ExtensionContext extensionContext, Dependencies dependencies) { var log = new LogAccessor().getLog(dependencies.logService(), getClass()); + var globalProcedures = dependencies.globalProcedures(); + var neo4jConfiguration = dependencies.config(); // OpenGDS edition customisations go here ExporterBuildersProviderService exporterBuildersProviderService = (__, ___) -> new NativeExportBuildersProvider(); // we always just offer native writes in OpenGDS + var exportLocation = ExportLocation.create(neo4jConfiguration); var metricsFacade = MetricsFacade.PASSTHROUGH_METRICS_FACADE; // no metrics in OpenGDS var modelCatalog = new OpenModelCatalogProvider().get(null); - var graphSageModelRepository = new DisableModelRepository(); // no model storing in OpenGDS - var neo4jConfiguration = dependencies.config(); - - var exportLocation = ExportLocation.create(neo4jConfiguration); - - var graphDataScienceExtensionBuilderAndAssociatedProducts = GraphDataScienceExtensionBuilder.create( + var graphDataScienceExtensionBuilderAndAssociatedProducts = OpenGraphDataScienceExtensionBuilder.create( log, + globalProcedures, neo4jConfiguration, - dependencies.globalProcedures(), - exportLocation, - Optional.empty(), // no extra checks in OpenGDS - Optional.empty(), // no extra checks in OpenGDS - Optional.empty(), // no extra checks in OpenGDS exporterBuildersProviderService, + exportLocation, metricsFacade, modelCatalog, - graphSageModelRepository + graphSageModelRepository, + Optional.empty(), // no extra checks in OpenGDS + Optional.empty(), // no extra checks in OpenGDS + Optional.empty() // no extra checks in OpenGDS ); var graphDataScienceExtensionBuilder = graphDataScienceExtensionBuilderAndAssociatedProducts.getLeft(); diff --git a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProvider.java b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProceduresProvider.java similarity index 96% rename from procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProvider.java rename to procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProceduresProvider.java index 9e4cf4d637..f28f8096da 100644 --- a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProvider.java +++ b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProceduresProvider.java @@ -62,7 +62,7 @@ /** * We use this at request time to construct the facade that the procedures call. */ -public class GraphDataScienceProvider implements ThrowingFunction { +public class GraphDataScienceProceduresProvider implements ThrowingFunction { private final AlgorithmMetaDataSetterService algorithmMetaDataSetterService = new AlgorithmMetaDataSetterService(); private final DatabaseIdAccessor databaseIdAccessor = new DatabaseIdAccessor(); private final KernelTransactionAccessor kernelTransactionAccessor = new KernelTransactionAccessor(); @@ -71,71 +71,75 @@ public class GraphDataScienceProvider implements ThrowingFunction> algorithmProcessingTemplateDecorator; - private final Optional> graphCatalogApplicationsDecorator; - private final Optional> modelCatalogApplicationsDecorator; - private final GraphCatalogProcedureFacadeFactory graphCatalogProcedureFacadeFactory; + private final AlgorithmProcedureFacadeBuilderFactory algorithmProcedureFacadeBuilderFactory; + private final DefaultsConfiguration defaultsConfiguration; private final DeprecatedProceduresMetricService deprecatedProceduresMetricService; private final ExporterBuildersProviderService exporterBuildersProviderService; + private final Supplier exportLocation; + private final GraphCatalogProcedureFacadeFactory graphCatalogProcedureFacadeFactory; private final GraphStoreCatalogService graphStoreCatalogService; + private final LimitsConfiguration limitsConfiguration; private final MemoryGuard memoryGuard; + private final ModelCatalog modelCatalog; + private final ModelRepository modelRepository; private final ProjectionMetricsService projectionMetricsService; private final TaskRegistryFactoryService taskRegistryFactoryService; private final TaskStoreService taskStoreService; private final UserLogServices userLogServices; - private final Configuration neo4jConfiguration; - private final ModelCatalog modelCatalog; - private final ModelRepository modelRepository; - private final Supplier exportLocation; - GraphDataScienceProvider( + private final Optional> algorithmProcessingTemplateDecorator; + private final Optional> graphCatalogApplicationsDecorator; + private final Optional> modelCatalogApplicationsDecorator; + + GraphDataScienceProceduresProvider( Log log, - DefaultsConfiguration defaultsConfiguration, - LimitsConfiguration limitsConfiguration, - AlgorithmProcedureFacadeBuilderFactory algorithmProcedureFacadeBuilderFactory, + Configuration neo4jConfiguration, AlgorithmMetricsService algorithmMetricsService, - Optional> algorithmProcessingTemplateDecorator, - Optional> graphCatalogApplicationsDecorator, - Optional> modelCatalogApplicationsDecorator, - GraphCatalogProcedureFacadeFactory graphCatalogProcedureFacadeFactory, + AlgorithmProcedureFacadeBuilderFactory algorithmProcedureFacadeBuilderFactory, + DefaultsConfiguration defaultsConfiguration, DeprecatedProceduresMetricService deprecatedProceduresMetricService, ExporterBuildersProviderService exporterBuildersProviderService, + Supplier exportLocation, + GraphCatalogProcedureFacadeFactory graphCatalogProcedureFacadeFactory, GraphStoreCatalogService graphStoreCatalogService, + LimitsConfiguration limitsConfiguration, MemoryGuard memoryGuard, + ModelCatalog modelCatalog, + ModelRepository modelRepository, ProjectionMetricsService projectionMetricsService, TaskRegistryFactoryService taskRegistryFactoryService, TaskStoreService taskStoreService, UserLogServices userLogServices, - Configuration neo4jConfiguration, - ModelCatalog modelCatalog, - ModelRepository modelRepository, - Supplier exportLocation + Optional> algorithmProcessingTemplateDecorator, + Optional> graphCatalogApplicationsDecorator, + Optional> modelCatalogApplicationsDecorator ) { this.log = log; - this.defaultsConfiguration = defaultsConfiguration; - this.limitsConfiguration = limitsConfiguration; - this.algorithmProcedureFacadeBuilderFactory = algorithmProcedureFacadeBuilderFactory; + this.neo4jConfiguration = neo4jConfiguration; + this.algorithmMetricsService = algorithmMetricsService; - this.algorithmProcessingTemplateDecorator = algorithmProcessingTemplateDecorator; - this.graphCatalogApplicationsDecorator = graphCatalogApplicationsDecorator; - this.modelCatalogApplicationsDecorator = modelCatalogApplicationsDecorator; - this.graphCatalogProcedureFacadeFactory = graphCatalogProcedureFacadeFactory; + this.algorithmProcedureFacadeBuilderFactory = algorithmProcedureFacadeBuilderFactory; + this.defaultsConfiguration = defaultsConfiguration; this.deprecatedProceduresMetricService = deprecatedProceduresMetricService; this.exporterBuildersProviderService = exporterBuildersProviderService; + this.exportLocation = exportLocation; + this.graphCatalogProcedureFacadeFactory = graphCatalogProcedureFacadeFactory; this.graphStoreCatalogService = graphStoreCatalogService; + this.limitsConfiguration = limitsConfiguration; this.memoryGuard = memoryGuard; + this.modelCatalog = modelCatalog; + this.modelRepository = modelRepository; this.projectionMetricsService = projectionMetricsService; this.taskRegistryFactoryService = taskRegistryFactoryService; this.taskStoreService = taskStoreService; this.userLogServices = userLogServices; - this.neo4jConfiguration = neo4jConfiguration; - this.modelCatalog = modelCatalog; - this.modelRepository = modelRepository; - this.exportLocation = exportLocation; + + this.algorithmProcessingTemplateDecorator = algorithmProcessingTemplateDecorator; + this.graphCatalogApplicationsDecorator = graphCatalogApplicationsDecorator; + this.modelCatalogApplicationsDecorator = modelCatalogApplicationsDecorator; } @Override @@ -147,7 +151,7 @@ public GraphDataScienceProcedures apply(Context context) throws ProcedureExcepti var graphDatabaseService = context.graphDatabaseAPI(); var databaseId = databaseIdAccessor.getDatabaseId(graphDatabaseService); - var writeContext = constructWriteContext(context, graphDatabaseService); + var writeContext = createWriteContext(context, graphDatabaseService); var procedureReturnColumns = new ProcedureCallContextReturnColumns(procedureCallContext); var terminationFlag = terminationFlagAccessor.createTerminationFlag(kernelTransaction); @@ -207,7 +211,7 @@ public GraphDataScienceProcedures apply(Context context) throws ProcedureExcepti ); } - private WriteContext constructWriteContext(Context context, GraphDatabaseService graphDatabaseService) { + private WriteContext createWriteContext(Context context, GraphDatabaseService graphDatabaseService) { var exportBuildersProvider = exporterBuildersProviderService.identifyExportBuildersProvider( graphDatabaseService, neo4jConfiguration diff --git a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProviderFactory.java b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProceduresProviderFactory.java similarity index 81% rename from procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProviderFactory.java rename to procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProceduresProviderFactory.java index bcf43096bc..db93ca31d6 100644 --- a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProviderFactory.java +++ b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceProceduresProviderFactory.java @@ -48,7 +48,7 @@ * This is a way to squirrel away some dull code. * We want to keep Neo4j out from here, this could be reusable. */ -final class GraphDataScienceProviderFactory { +final class GraphDataScienceProceduresProviderFactory { /** * These are currently global singletons; when they seize to be, this is the place to initialise them. * They are similar in lifecycle to {@link org.neo4j.gds.core.loading.GraphStoreCatalogService} @@ -56,49 +56,49 @@ final class GraphDataScienceProviderFactory { private final DefaultsConfiguration defaultsConfiguration = DefaultsConfiguration.Instance; private final LimitsConfiguration limitsConfiguration = LimitsConfiguration.Instance; - private final Log log; - // Graph catalog state initialised here, currently just a front for a big shared singleton private final GraphStoreCatalogService graphStoreCatalogService = new GraphStoreCatalogService(); - private final Optional> algorithmProcessingTemplateDecorator; - private final Optional> graphCatalogApplicationsDecorator; - private final Optional> modelCatalogApplicationsDecorator; + private final Log log; + + private final Configuration neo4jConfiguration; private final ExporterBuildersProviderService exporterBuildersProviderService; + private final Supplier exportLocation; private final MemoryGauge memoryGauge; private final MetricsFacade metricsFacade; private final ModelCatalog modelCatalog; - private final Configuration neo4jConfiguration; private final ModelRepository modelRepository; - private final Supplier exportLocation; + private final Optional> algorithmProcessingTemplateDecorator; + private final Optional> graphCatalogApplicationsDecorator; + private final Optional> modelCatalogApplicationsDecorator; - private GraphDataScienceProviderFactory( + GraphDataScienceProceduresProviderFactory( Log log, - Optional> algorithmProcessingTemplateDecorator, - Optional> graphCatalogApplicationsDecorator, - Optional> modelCatalogApplicationsDecorator, + Configuration neo4jConfiguration, ExporterBuildersProviderService exporterBuildersProviderService, + Supplier exportLocation, MemoryGauge memoryGauge, MetricsFacade metricsFacade, ModelCatalog modelCatalog, - Configuration neo4jConfiguration, ModelRepository modelRepository, - Supplier exportLocation + Optional> algorithmProcessingTemplateDecorator, + Optional> graphCatalogApplicationsDecorator, + Optional> modelCatalogApplicationsDecorator ) { this.log = log; - this.algorithmProcessingTemplateDecorator = algorithmProcessingTemplateDecorator; - this.graphCatalogApplicationsDecorator = graphCatalogApplicationsDecorator; - this.modelCatalogApplicationsDecorator = modelCatalogApplicationsDecorator; + this.neo4jConfiguration = neo4jConfiguration; this.exporterBuildersProviderService = exporterBuildersProviderService; + this.exportLocation = exportLocation; this.memoryGauge = memoryGauge; this.metricsFacade = metricsFacade; this.modelCatalog = modelCatalog; - this.neo4jConfiguration = neo4jConfiguration; this.modelRepository = modelRepository; - this.exportLocation = exportLocation; + this.algorithmProcessingTemplateDecorator = algorithmProcessingTemplateDecorator; + this.graphCatalogApplicationsDecorator = graphCatalogApplicationsDecorator; + this.modelCatalogApplicationsDecorator = modelCatalogApplicationsDecorator; } - GraphDataScienceProvider createGraphDataScienceProvider( + GraphDataScienceProceduresProvider createGraphDataScienceProvider( TaskRegistryFactoryService taskRegistryFactoryService, TaskStoreService taskStoreService, boolean useMaxMemoryEstimation, @@ -112,56 +112,28 @@ GraphDataScienceProvider createGraphDataScienceProvider( var memoryGuard = new DefaultMemoryGuard(log, useMaxMemoryEstimation, memoryGauge); - return new GraphDataScienceProvider( + return new GraphDataScienceProceduresProvider( log, - defaultsConfiguration, - limitsConfiguration, - algorithmFacadeBuilderFactory, + neo4jConfiguration, metricsFacade.algorithmMetrics(), - algorithmProcessingTemplateDecorator, - graphCatalogApplicationsDecorator, - modelCatalogApplicationsDecorator, - catalogProcedureFacadeFactory, + algorithmFacadeBuilderFactory, + defaultsConfiguration, metricsFacade.deprecatedProcedures(), exporterBuildersProviderService, + exportLocation, + catalogProcedureFacadeFactory, graphStoreCatalogService, + limitsConfiguration, memoryGuard, + modelCatalog, + modelRepository, metricsFacade.projectionMetrics(), taskRegistryFactoryService, taskStoreService, userLogServices, - neo4jConfiguration, - modelCatalog, - modelRepository, - exportLocation - ); - } - - static GraphDataScienceProviderFactory create( - Log log, - Supplier exportLocation, - Optional> algorithmProcessingTemplateDecorator, - Optional> graphCatalogApplicationsDecorator, - Optional> modelCatalogApplicationsDecorator, - ExporterBuildersProviderService exporterBuildersProviderService, - MemoryGauge memoryGauge, - MetricsFacade metricsFacade, - ModelCatalog modelCatalog, - Configuration neo4jConfiguration, - ModelRepository modelRepository - ) { - return new GraphDataScienceProviderFactory( - log, algorithmProcessingTemplateDecorator, graphCatalogApplicationsDecorator, - modelCatalogApplicationsDecorator, - exporterBuildersProviderService, - memoryGauge, - metricsFacade, - modelCatalog, - neo4jConfiguration, - modelRepository, - exportLocation + modelCatalogApplicationsDecorator ); } diff --git a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceExtensionBuilder.java b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/OpenGraphDataScienceExtensionBuilder.java similarity index 91% rename from procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceExtensionBuilder.java rename to procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/OpenGraphDataScienceExtensionBuilder.java index b752ff313c..f048a66dcf 100644 --- a/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/GraphDataScienceExtensionBuilder.java +++ b/procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/OpenGraphDataScienceExtensionBuilder.java @@ -56,13 +56,13 @@ * in terms of the components it registers and the lifecycles it spawns. * We encapsulate it here, with allowances for customisations. */ -public final class GraphDataScienceExtensionBuilder { +public final class OpenGraphDataScienceExtensionBuilder { // fundamentals private final Log log; private final ComponentRegistration componentRegistration; // structural - private final GraphDataScienceProviderFactory graphDataScienceProviderFactory; + private final GraphDataScienceProceduresProviderFactory graphDataScienceProceduresProviderFactory; // edition specifics private final MetricsFacade metricsFacade; @@ -75,10 +75,10 @@ public final class GraphDataScienceExtensionBuilder { private final UserLogServices userLogServices; private final Lifecycle gcListener; - private GraphDataScienceExtensionBuilder( + private OpenGraphDataScienceExtensionBuilder( Log log, ComponentRegistration componentRegistration, - GraphDataScienceProviderFactory graphDataScienceProviderFactory, + GraphDataScienceProceduresProviderFactory graphDataScienceProceduresProviderFactory, MetricsFacade metricsFacade, ModelCatalog modelCatalog, TaskStoreService taskStoreService, @@ -89,7 +89,7 @@ private GraphDataScienceExtensionBuilder( ) { this.log = log; this.componentRegistration = componentRegistration; - this.graphDataScienceProviderFactory = graphDataScienceProviderFactory; + this.graphDataScienceProceduresProviderFactory = graphDataScienceProceduresProviderFactory; this.metricsFacade = metricsFacade; this.modelCatalog = modelCatalog; this.taskStoreService = taskStoreService; @@ -103,18 +103,17 @@ private GraphDataScienceExtensionBuilder( * We want to build a GDS, we receive a few customisations and are able to read configuration, * and all the rest of the machinery goes here */ - public static Triple create( + public static Triple create( Log log, - Configuration neo4jConfiguration, GlobalProcedures globalProcedures, - Supplier exportLocation, - Optional> algorithmProcessingTemplateDecorator, - Optional> graphCatalogApplicationsDecorator, - Optional> modelCatalogApplicationsDecorator, - ExporterBuildersProviderService exporterBuildersProviderService, + Configuration neo4jConfiguration, + ExporterBuildersProviderService exporterBuildersProviderService, Supplier exportLocation, MetricsFacade metricsFacade, ModelCatalog modelCatalog, - ModelRepository modelRepository + ModelRepository modelRepository, + Optional> algorithmProcessingTemplateDecorator, + Optional> graphCatalogApplicationsDecorator, + Optional> modelCatalogApplicationsDecorator ) { // Read some configuration used to select behaviour var progressTrackingEnabled = neo4jConfiguration.get(ProgressFeatureSettings.progress_tracking_enabled); @@ -149,21 +148,21 @@ public static Triple