Skip to content

Commit

Permalink
migrate estimation cli toundirected to application layer
Browse files Browse the repository at this point in the history
  • Loading branch information
lassewesth committed Dec 4, 2024
1 parent caf819e commit 327b131
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 207 deletions.
1 change: 1 addition & 0 deletions algo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ dependencies {

testImplementation project(':centrality-algorithms')
testImplementation project(':community-algorithms')
testImplementation project(':miscellaneous-algorithms')
testImplementation project(':node-embedding-algorithms')
testImplementation project(':path-finding-algorithms')
testImplementation project(':similarity-algorithms')
Expand Down

This file was deleted.

24 changes: 15 additions & 9 deletions algo/src/test/java/org/neo4j/gds/undirected/ToUndirectedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@
import org.neo4j.gds.RelationshipType;
import org.neo4j.gds.api.Graph;
import org.neo4j.gds.api.GraphStore;
import org.neo4j.gds.applications.algorithms.machinery.ProgressTrackerCreator;
import org.neo4j.gds.applications.algorithms.machinery.RequestScopedDependencies;
import org.neo4j.gds.applications.algorithms.miscellaneous.MiscellaneousAlgorithms;
import org.neo4j.gds.core.Aggregation;
import org.neo4j.gds.core.concurrency.DefaultPool;
import org.neo4j.gds.core.loading.SingleTypeRelationships;
import org.neo4j.gds.core.utils.progress.EmptyTaskRegistryFactory;
import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker;
import org.neo4j.gds.core.utils.warnings.EmptyUserLogRegistryFactory;
import org.neo4j.gds.extension.GdlExtension;
import org.neo4j.gds.extension.GdlGraph;
import org.neo4j.gds.extension.Inject;
Expand Down Expand Up @@ -312,22 +316,24 @@ void shouldAggregateWithPropertiesAndLocalAggregation() {
@Test
void shouldLogProgress() {
var log = new GdsTestLog();
var requestScopedDependencies = RequestScopedDependencies.builder()
.taskRegistryFactory(EmptyTaskRegistryFactory.INSTANCE)
.terminationFlag(TerminationFlag.RUNNING_TRUE)
.userLogRegistryFactory(EmptyUserLogRegistryFactory.INSTANCE)
.build();
var progressTrackerCreator = new ProgressTrackerCreator(log, requestScopedDependencies);
var miscellaneousAlgorithms = new MiscellaneousAlgorithms(
progressTrackerCreator,
requestScopedDependencies.terminationFlag()
);

var config = ToUndirectedConfigImpl
.builder()
.concurrency(4)
.relationshipType("T1")
.mutateRelationshipType("T2")
.build();

ToUndirected toUndirected = new ToUndirectedAlgorithmFactory().build(
directedGraphStore,
config,
log,
EmptyTaskRegistryFactory.INSTANCE
);

toUndirected.compute();
miscellaneousAlgorithms.toUndirected(directedGraphStore, config);

var messagesInOrder = log.getMessages(INFO);

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
import java.util.Set;
import java.util.stream.Collectors;

class MiscellaneousAlgorithms {
public class MiscellaneousAlgorithms {
private final AlgorithmMachinery algorithmMachinery = new AlgorithmMachinery();

private final ProgressTrackerCreator progressTrackerCreator;
private final TerminationFlag terminationFlag;

MiscellaneousAlgorithms(ProgressTrackerCreator progressTrackerCreator, TerminationFlag terminationFlag) {
public MiscellaneousAlgorithms(ProgressTrackerCreator progressTrackerCreator, TerminationFlag terminationFlag) {
this.progressTrackerCreator = progressTrackerCreator;
this.terminationFlag = terminationFlag;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ ScalePropertiesResult scaleProperties(Graph graph, ScalePropertiesBaseConfig con
);
}

SingleTypeRelationships toUndirected(GraphStore graphStore, ToUndirectedConfig configuration) {
public SingleTypeRelationships toUndirected(GraphStore graphStore, ToUndirectedConfig configuration) {
var task = Tasks.task(
AlgorithmLabel.ToUndirected.asString(),
Tasks.leaf("Create Undirected Relationships", graphStore.nodeCount()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ public MemoryEstimateResult scaleProperties(
}

public MemoryEstimation toUndirected(ToUndirectedConfig configuration) {
return new ToUndirectedMemoryEstimateDefinition(ToUndirectedConfigTransformer.toMemoryEstimateParameters(configuration)).memoryEstimation();
var parameters = ToUndirectedConfigTransformer.toMemoryEstimateParameters(configuration);

return new ToUndirectedMemoryEstimateDefinition(parameters).memoryEstimation();
}

public MemoryEstimateResult toUndirected(
ToUndirectedConfig configuration,
Object graphNameOrConfiguration
) {
var memoryEstimation = toUndirected(configuration);

return algorithmEstimationTemplate.estimate(
configuration,
graphNameOrConfiguration,
memoryEstimation
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.neo4j.gds.applications.algorithms.machinery.AlgorithmProcessingTimings;
import org.neo4j.gds.procedures.algorithms.results.StandardMutateResult;
import org.neo4j.gds.result.AbstractResultBuilder;

import java.util.Map;

Expand Down Expand Up @@ -57,26 +56,4 @@ public static ToUndirectedMutateResult emptyFrom(
configurationMap
);
}

public static class Builder extends AbstractResultBuilder<ToUndirectedMutateResult> {
private long inputRelationships;

public Builder withInputRelationships(long inputRelationships) {
this.inputRelationships = inputRelationships;
return this;
}

@Override
public ToUndirectedMutateResult build() {
return new ToUndirectedMutateResult(
preProcessingMillis,
computeMillis,
mutateMillis,
0,
inputRelationships,
relationshipsWritten,
config.toMap()
);
}
}
}

0 comments on commit 327b131

Please sign in to comment.