diff --git a/core-utils/src/main/java/org/neo4j/gds/core/utils/TimeUtil.java b/core-utils/src/main/java/org/neo4j/gds/core/utils/TimeUtil.java index 4de96515a9..e0492fdf40 100644 --- a/core-utils/src/main/java/org/neo4j/gds/core/utils/TimeUtil.java +++ b/core-utils/src/main/java/org/neo4j/gds/core/utils/TimeUtil.java @@ -19,18 +19,14 @@ */ package org.neo4j.gds.core.utils; -import org.neo4j.gds.settings.Neo4jSettings; - import java.time.Clock; import java.time.ZoneId; import java.time.ZonedDateTime; public final class TimeUtil { - public static ZonedDateTime now() { - var zoneId = Neo4jSettings.dbTemporalTimezone().defaultValue(); + public static ZonedDateTime now(ZoneId zoneId) { return ZonedDateTime.now(Clock.system(zoneId != null ? zoneId : ZoneId.systemDefault())); } - private TimeUtil() {} } diff --git a/core/src/main/java/org/neo4j/gds/core/loading/CSRGraphStore.java b/core/src/main/java/org/neo4j/gds/core/loading/CSRGraphStore.java index ecfeee05e6..2b1428c317 100644 --- a/core/src/main/java/org/neo4j/gds/core/loading/CSRGraphStore.java +++ b/core/src/main/java/org/neo4j/gds/core/loading/CSRGraphStore.java @@ -57,6 +57,7 @@ import org.neo4j.gds.core.utils.TimeUtil; import org.neo4j.gds.utils.StringJoining; +import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Collection; import java.util.Collections; @@ -94,6 +95,7 @@ public final class CSRGraphStore implements GraphStore { private NodePropertyStore nodeProperties; + private final ZoneId zoneId; private final ZonedDateTime creationTime; private ZonedDateTime modificationTime; @@ -105,7 +107,8 @@ private CSRGraphStore( NodePropertyStore nodeProperties, Map relationships, GraphPropertyStore graphProperties, - Concurrency concurrency + Concurrency concurrency, + ZoneId zoneId ) { this.databaseInfo = databaseInfo; this.capabilities = capabilities; @@ -121,7 +124,8 @@ private CSRGraphStore( this.relationships = new HashMap<>(relationships); this.concurrency = concurrency; - this.creationTime = TimeUtil.now(); + this.zoneId = zoneId; + this.creationTime = TimeUtil.now(zoneId); this.modificationTime = this.creationTime; } @@ -133,7 +137,8 @@ public static CSRGraphStore of( Nodes nodes, RelationshipImportResult relationshipImportResult, Optional graphProperties, - Concurrency concurrency + Concurrency concurrency, + Optional zoneId ) { return new CSRGraphStore( databaseInfo, @@ -143,7 +148,8 @@ public static CSRGraphStore of( nodes.properties(), relationshipImportResult.importResults(), graphProperties.orElseGet(GraphPropertyStore::empty), - concurrency + concurrency, + zoneId.orElseGet(ZoneId::systemDefault) ); } @@ -585,7 +591,7 @@ public long nodeCount() { private synchronized void updateGraphStore(Consumer updateFunction) { updateFunction.accept(this); - this.modificationTime = TimeUtil.now(); + this.modificationTime = TimeUtil.now(zoneId); } private CSRGraph createGraph( diff --git a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/TrainingPipeline.java b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/TrainingPipeline.java index 60178f369b..2c0f2df5fa 100644 --- a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/TrainingPipeline.java +++ b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/TrainingPipeline.java @@ -24,6 +24,7 @@ import org.neo4j.gds.ml.models.automl.TunableTrainerConfig; import org.neo4j.gds.core.utils.TimeUtil; +import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.EnumMap; @@ -52,10 +53,10 @@ public static Map>> toMapParameterSpace(Map(); this.featureSteps = new ArrayList<>(); - this.creationTime = TimeUtil.now(); + this.creationTime = TimeUtil.now(zoneId); this.trainingParameterSpace = new EnumMap<>(TrainingMethod.class); this.autoTuningConfig = AutoTuningConfig.DEFAULT_CONFIG; diff --git a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/linkPipeline/LinkPredictionTrainingPipeline.java b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/linkPipeline/LinkPredictionTrainingPipeline.java index 8acf3a059a..1ed5fe8501 100644 --- a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/linkPipeline/LinkPredictionTrainingPipeline.java +++ b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/linkPipeline/LinkPredictionTrainingPipeline.java @@ -26,6 +26,7 @@ import org.neo4j.gds.executor.ExecutionContext; import org.neo4j.gds.ml.pipeline.ExecutableNodePropertyStep; import org.neo4j.gds.ml.pipeline.TrainingPipeline; +import org.neo4j.gds.settings.Neo4jSettings; import java.util.ArrayList; import java.util.HashMap; @@ -44,7 +45,7 @@ public class LinkPredictionTrainingPipeline extends TrainingPipeline dataSplits) { private class BogusNodePropertyPipeline extends TrainingPipeline { - BogusNodePropertyPipeline() {super(TrainingType.REGRESSION);} + BogusNodePropertyPipeline() {super(TrainingType.REGRESSION, Neo4jSettings.dbTemporalTimezone().defaultValue());} @Override public List nodePropertySteps() { @@ -293,7 +294,7 @@ public void validateFeatureProperties(GraphStore graphStore, Collection { - FailingNodePropertyPipeline() {super(TrainingType.CLASSIFICATION);} + FailingNodePropertyPipeline() {super(TrainingType.CLASSIFICATION, Neo4jSettings.dbTemporalTimezone().defaultValue());} @Override public List nodePropertySteps() {