From ff1fc0907695c8242d59559c9463677a67e73b39 Mon Sep 17 00:00:00 2001 From: Lasse Westh-Nielsen Date: Fri, 16 Aug 2024 15:46:34 +0200 Subject: [PATCH] cleanup --- .../neo4j/gds/executor/ExecutionContext.java | 18 ------ .../src/main/java/org/neo4j/gds/BaseProc.java | 31 +---------- .../java/org/neo4j/gds/BaseProcUnitTest.java | 55 ------------------- 3 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 proc/test/src/test/java/org/neo4j/gds/BaseProcUnitTest.java diff --git a/executor/src/main/java/org/neo4j/gds/executor/ExecutionContext.java b/executor/src/main/java/org/neo4j/gds/executor/ExecutionContext.java index edae2fe1da..eacf5913b8 100644 --- a/executor/src/main/java/org/neo4j/gds/executor/ExecutionContext.java +++ b/executor/src/main/java/org/neo4j/gds/executor/ExecutionContext.java @@ -35,7 +35,6 @@ import org.neo4j.gds.core.utils.warnings.UserLogRegistryFactory; import org.neo4j.gds.core.write.NodePropertyExporterBuilder; import org.neo4j.gds.core.write.RelationshipExporterBuilder; -import org.neo4j.gds.core.write.RelationshipStreamExporterBuilder; import org.neo4j.gds.logging.Log; import org.neo4j.gds.metrics.MetricsFacade; import org.neo4j.gds.procedures.algorithms.AlgorithmsProcedureFacade; @@ -76,9 +75,6 @@ public interface ExecutionContext { @Nullable AlgorithmsProcedureFacade algorithmsProcedureFacade(); - @Nullable - RelationshipStreamExporterBuilder relationshipStreamExporterBuilder(); - @Nullable RelationshipExporterBuilder relationshipExporterBuilder(); @@ -93,14 +89,6 @@ default ExecutionContext withNodePropertyExporterBuilder(NodePropertyExporterBui .build(); } - default ExecutionContext withRelationshipStreamExporterBuilder(RelationshipStreamExporterBuilder relationshipStreamExporterBuilder) { - return ImmutableExecutionContext - .builder() - .from(this) - .relationshipStreamExporterBuilder(relationshipStreamExporterBuilder) - .build(); - } - default ExecutionContext withRelationshipExporterBuilder(RelationshipExporterBuilder relationshipExporterBuilder) { return ImmutableExecutionContext .builder() @@ -182,7 +170,6 @@ public boolean isGdsAdmin() { @Override public MetricsFacade metricsFacade() { return MetricsFacade.PASSTHROUGH_METRICS_FACADE; - } @Override @@ -190,11 +177,6 @@ public AlgorithmsProcedureFacade algorithmsProcedureFacade() { return null; } - @Override - public @Nullable RelationshipStreamExporterBuilder relationshipStreamExporterBuilder() { - return null; - } - @Override public @Nullable RelationshipExporterBuilder relationshipExporterBuilder() { return null; diff --git a/proc/common/src/main/java/org/neo4j/gds/BaseProc.java b/proc/common/src/main/java/org/neo4j/gds/BaseProc.java index f5f2545b60..f300f8c977 100644 --- a/proc/common/src/main/java/org/neo4j/gds/BaseProc.java +++ b/proc/common/src/main/java/org/neo4j/gds/BaseProc.java @@ -20,22 +20,18 @@ package org.neo4j.gds; import org.neo4j.gds.api.DatabaseId; -import org.neo4j.gds.applications.graphstorecatalog.GraphStoreFromCatalogLoader; import org.neo4j.gds.compat.GraphDatabaseApiProxy; -import org.neo4j.gds.config.BaseConfig; -import org.neo4j.gds.core.CypherMapAccess; import org.neo4j.gds.core.Username; -import org.neo4j.gds.core.loading.GraphStoreCatalogEntry; import org.neo4j.gds.core.utils.progress.TaskRegistryFactory; import org.neo4j.gds.core.utils.warnings.UserLogRegistryFactory; import org.neo4j.gds.executor.ExecutionContext; import org.neo4j.gds.executor.ImmutableExecutionContext; +import org.neo4j.gds.logging.LogAdapter; import org.neo4j.gds.metrics.MetricsFacade; import org.neo4j.gds.procedures.GraphDataScienceProcedures; import org.neo4j.gds.procedures.ProcedureCallContextReturnColumns; import org.neo4j.gds.procedures.TransactionCloseableResourceRegistry; import org.neo4j.gds.procedures.TransactionNodeLookup; -import org.neo4j.gds.logging.LogAdapter; import org.neo4j.gds.procedures.integration.TransactionTerminationMonitor; import org.neo4j.gds.transaction.DatabaseTransactionContext; import org.neo4j.gds.transaction.EmptyTransactionContext; @@ -48,8 +44,6 @@ import org.neo4j.logging.Log; import org.neo4j.procedure.Context; -import java.util.function.Supplier; - public abstract class BaseProc { public static final String ESTIMATE_DESCRIPTION = "Returns an estimation of the memory consumption for that procedure."; @@ -88,16 +82,6 @@ protected String username() { return username.username(); } - protected GraphStoreCatalogEntry graphStoreFromCatalog(String graphName, BaseConfig config) { - return GraphStoreFromCatalogLoader.graphStoreFromCatalog( - graphName, - config, - username(), - databaseId(), - isGdsAdmin() - ); - } - protected boolean isGdsAdmin() { if (transaction == null) { // No transaction available (likely we're in a test), no-one is admin here @@ -109,19 +93,6 @@ protected boolean isGdsAdmin() { return transaction.securityContext().roles().contains(PREDEFINED_ADMIN_ROLE); } - protected final R runWithExceptionLogging(String message, Supplier supplier) { - try { - return supplier.get(); - } catch (Exception e) { - log.warn(message, e); - throw e; - } - } - - protected final void validateConfig(CypherMapAccess cypherConfig, BaseConfig config) { - cypherConfig.requireOnlyKeysFrom(config.configKeys()); - } - public ExecutionContext executionContext() { return databaseService == null ? ExecutionContext.EMPTY diff --git a/proc/test/src/test/java/org/neo4j/gds/BaseProcUnitTest.java b/proc/test/src/test/java/org/neo4j/gds/BaseProcUnitTest.java deleted file mode 100644 index d637d8fb43..0000000000 --- a/proc/test/src/test/java/org/neo4j/gds/BaseProcUnitTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) "Neo4j" - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.gds; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.neo4j.gds.compat.Neo4jProxy; -import org.neo4j.gds.compat.TestLog; - -import java.util.function.Supplier; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -class BaseProcUnitTest { - - private TestLog log; - - private BaseProc baseProc; - - @BeforeEach - void setup() { - log = Neo4jProxy.testLog(); - baseProc = new BaseProc() {}; - baseProc.log = log; - } - - @Test - void testRunWithExceptionLoggingWithSupplier() { - RuntimeException exception = new RuntimeException("Exception when using Supplier"); - Supplier supplier = () -> { - throw exception; - }; - - assertThrows(RuntimeException.class, () -> baseProc.runWithExceptionLogging("test message", supplier)); - assertTrue(log.containsMessage("warn", "test message - Exception when using Supplier")); - } -}