Skip to content

Commit 01ab2cc

Browse files
vnickolovDarthMaxIoannisPanagiotas
committed
Address review comments
Co-authored-by: Max Kießling <max.kiessling@neotechnology.com> Co-authored-by: Ioannis Panagiotas <ioannis.panagiotas@neotechnology.com>
1 parent 045d248 commit 01ab2cc

File tree

3 files changed

+37
-46
lines changed

3 files changed

+37
-46
lines changed

proc/community/src/main/java/org/neo4j/gds/leiden/LeidenStreamProc.java

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
*/
2020
package org.neo4j.gds.leiden;
2121

22-
import org.neo4j.gds.AlgoBaseProc;
23-
import org.neo4j.gds.AlgorithmFactory;
24-
import org.neo4j.gds.core.CypherMapWrapper;
25-
import org.neo4j.gds.core.utils.paged.HugeLongArray;
26-
import org.neo4j.gds.executor.ComputationResultConsumer;
22+
import org.neo4j.gds.BaseProc;
2723
import org.neo4j.gds.executor.ProcedureExecutor;
2824
import org.neo4j.procedure.Description;
2925
import org.neo4j.procedure.Name;
@@ -34,15 +30,7 @@
3430

3531
import static org.neo4j.procedure.Mode.READ;
3632

37-
public class LeidenStreamProc extends AlgoBaseProc<Leiden, HugeLongArray, LeidenStreamConfig, LeidenStreamProc.StreamResult> {
38-
// Config
39-
// relationshipWeightProperty
40-
// maxIterations
41-
42-
// Output
43-
// nodeId
44-
// communityId
45-
33+
public class LeidenStreamProc extends BaseProc {
4634
static final String DESCRIPTION =
4735
"Leiden is a community detection algorithm, which guarantees that communities are well connected";
4836

@@ -52,37 +40,9 @@ public Stream<StreamResult> stream(
5240
@Name(value = "graphName") String graphName,
5341
@Name(value = "configuration", defaultValue = "{}") Map<String, Object> configuration
5442
) {
55-
var streamSpec = new LeidenStreamSpec();
56-
5743
return new ProcedureExecutor<>(
58-
streamSpec,
44+
new LeidenStreamSpec(),
5945
executionContext()
6046
).compute(graphName, configuration, true, true);
6147
}
62-
63-
@Override
64-
public AlgorithmFactory<?, Leiden, LeidenStreamConfig> algorithmFactory() {
65-
return new LeidenStreamSpec().algorithmFactory();
66-
}
67-
68-
@Override
69-
public ComputationResultConsumer<Leiden, HugeLongArray, LeidenStreamConfig, Stream<StreamResult>> computationResultConsumer() {
70-
return new LeidenStreamSpec().computationResultConsumer();
71-
}
72-
73-
@Override
74-
protected LeidenStreamConfig newConfig(String username, CypherMapWrapper config) {
75-
return new LeidenStreamSpec().newConfigFunction().apply(username, config);
76-
}
77-
78-
public static class StreamResult {
79-
80-
public final long nodeId;
81-
public final long communityId;
82-
83-
StreamResult(long nodeId, long communityId) {
84-
this.nodeId = nodeId;
85-
this.communityId = communityId;
86-
}
87-
}
8848
}

proc/community/src/main/java/org/neo4j/gds/leiden/LeidenStreamSpec.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import static org.neo4j.gds.leiden.LeidenStreamProc.DESCRIPTION;
3333

3434
@GdsCallable(name = "gds.alpha.leiden.stream", description = DESCRIPTION, executionMode = STREAM)
35-
public class LeidenStreamSpec implements AlgorithmSpec<Leiden, HugeLongArray, LeidenStreamConfig, Stream<LeidenStreamProc.StreamResult>, LeidenAlgorithmFactory<LeidenStreamConfig>> {
35+
public class LeidenStreamSpec implements AlgorithmSpec<Leiden, HugeLongArray, LeidenStreamConfig, Stream<StreamResult>, LeidenAlgorithmFactory<LeidenStreamConfig>> {
3636
@Override
3737
public String name() {
3838
return "LeidenStream";
@@ -49,12 +49,12 @@ public NewConfigFunction<LeidenStreamConfig> newConfigFunction() {
4949
}
5050

5151
@Override
52-
public ComputationResultConsumer<Leiden, HugeLongArray, LeidenStreamConfig, Stream<LeidenStreamProc.StreamResult>> computationResultConsumer() {
52+
public ComputationResultConsumer<Leiden, HugeLongArray, LeidenStreamConfig, Stream<StreamResult>> computationResultConsumer() {
5353
return (computationResult, executionContext) -> {
5454
var graph = computationResult.graph();
5555
var communities = computationResult.result();
5656
return LongStream.range(0, graph.nodeCount())
57-
.mapToObj(nodeId -> new LeidenStreamProc.StreamResult(graph.toOriginalNodeId(nodeId), communities.get(nodeId)));
57+
.mapToObj(nodeId -> new StreamResult(graph.toOriginalNodeId(nodeId), communities.get(nodeId)));
5858
};
5959
}
6060
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.gds.leiden;
21+
22+
public final class StreamResult {
23+
24+
public final long nodeId;
25+
public final long communityId;
26+
27+
StreamResult(long nodeId, long communityId) {
28+
this.nodeId = nodeId;
29+
this.communityId = communityId;
30+
}
31+
}

0 commit comments

Comments
 (0)