Skip to content

Commit c5d888d

Browse files
authored
Merge pull request #10317 from FlorentinD/cypher-surface/graph-producing-endpoints
cypher surface/graph producing endpoints
2 parents d69ed34 + efb9f07 commit c5d888d

File tree

7 files changed

+95
-83
lines changed

7 files changed

+95
-83
lines changed

applications/graph-store-catalog-results/src/main/java/org/neo4j/gds/applications/graphstorecatalog/GraphGenerationStats.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,29 @@
2222
import java.util.Map;
2323

2424
public class GraphGenerationStats {
25-
public String name;
26-
public long nodes;
27-
public long relationships;
28-
@SuppressWarnings("WeakerAccess")
29-
public long generateMillis;
30-
@SuppressWarnings("WeakerAccess")
31-
public Long relationshipSeed;
32-
public double averageDegree;
33-
public Object relationshipDistribution;
34-
public Object relationshipProperty;
25+
public final String name;
26+
public final long nodes;
27+
public final long relationships;
28+
public final long generateMillis;
29+
public final Long relationshipSeed;
30+
public final double averageDegree;
31+
public final Object relationshipDistribution;
32+
public final Object relationshipProperty;
3533

36-
GraphGenerationStats(
34+
public GraphGenerationStats(
3735
String graphName,
36+
long nodes,
37+
long relationships,
38+
long generateMillis,
3839
double averageDegree,
3940
String relationshipDistribution,
4041
Map<String, Object> relationshipProperty,
4142
Long relationshipSeed
4243
) {
4344
this.name = graphName;
45+
this.nodes = nodes;
46+
this.relationships = relationships;
47+
this.generateMillis = generateMillis;
4448
this.averageDegree = averageDegree;
4549
this.relationshipDistribution = relationshipDistribution;
4650
this.relationshipProperty = relationshipProperty;

applications/graph-store-catalog-results/src/main/java/org/neo4j/gds/applications/graphstorecatalog/RandomWalkSamplingResult.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,6 @@
1919
*/
2020
package org.neo4j.gds.applications.graphstorecatalog;
2121

22-
import org.neo4j.gds.core.loading.GraphProjectResult;
23-
24-
public class RandomWalkSamplingResult extends GraphProjectResult {
25-
public final String fromGraphName;
26-
public final long startNodeCount;
27-
28-
RandomWalkSamplingResult(
29-
String graphName,
30-
String fromGraphName,
31-
long nodeCount,
32-
long relationshipCount,
33-
long startNodeCount,
34-
long projectMillis
35-
) {
36-
super(graphName, nodeCount, relationshipCount, projectMillis);
37-
this.fromGraphName = fromGraphName;
38-
this.startNodeCount = startNodeCount;
39-
}
22+
public record RandomWalkSamplingResult(String graphName, String fromGraphName, long nodeCount, long relationshipCount,
23+
long startNodeCount, long projectMillis) {
4024
}

applications/graph-store-catalog/src/main/java/org/neo4j/gds/applications/graphstorecatalog/GenerateGraphApplication.java

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

22+
import org.apache.commons.lang3.mutable.MutableLong;
2223
import org.neo4j.gds.api.DatabaseId;
2324
import org.neo4j.gds.api.GraphStore;
2425
import org.neo4j.gds.api.schema.Direction;
@@ -71,15 +72,11 @@ private GraphGenerationStats generateGraph(
7172
long averageDegree,
7273
RandomGraphGeneratorConfig config
7374
) {
74-
var stats = new GraphGenerationStats(
75-
name,
76-
averageDegree,
77-
config.relationshipDistribution().name(),
78-
config.relationshipProperty(),
79-
config.relationshipSeed()
80-
);
75+
var generateMillis = new MutableLong();
76+
var nodes = 0L;
77+
var relationships = 0L;
8178

82-
try (ProgressTimer ignored = ProgressTimer.start(time -> stats.generateMillis = time)) {
79+
try (ProgressTimer ignored = ProgressTimer.start(generateMillis::setValue)) {
8380
RandomGraphGenerator generator = initializeGraphGenerator(config);
8481

8582
HugeGraph graph = generator.generate();
@@ -95,13 +92,22 @@ private GraphGenerationStats generateGraph(
9592
config.readConcurrency()
9693
);
9794

98-
stats.nodes = graphStore.nodeCount();
99-
stats.relationships = graphStore.relationshipCount();
95+
nodes = graphStore.nodeCount();
96+
relationships = graphStore.relationshipCount();
10097

10198
graphStoreCatalogService.set(config, graphStore);
10299
}
103100

104-
return stats;
101+
return new GraphGenerationStats(
102+
name,
103+
nodes,
104+
relationships,
105+
generateMillis.longValue(),
106+
averageDegree,
107+
config.relationshipDistribution().name(),
108+
config.relationshipProperty(),
109+
config.relationshipSeed()
110+
);
105111
}
106112

107113
static RandomGraphGenerator initializeGraphGenerator(RandomGraphGeneratorConfig config) {

applications/graph-store-catalog/src/test/java/org/neo4j/gds/applications/graphstorecatalog/GraphSamplingApplicationTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void shouldSampleRWR(Map<String, Object> mapConfiguration, long expectedNodeCoun
126126
RWR
127127
);
128128

129-
assertThat(result.nodeCount).isEqualTo(expectedNodeCount);
129+
assertThat(result.nodeCount()).isEqualTo(expectedNodeCount);
130130

131131
assertThat(
132132
GraphStoreCatalog.exists(
@@ -166,7 +166,7 @@ void shouldSampleCNARW(Map<String, Object> mapConfiguration, long expectedNodeCo
166166
CNARW
167167
);
168168

169-
assertThat(result.nodeCount).isEqualTo(expectedNodeCount);
169+
assertThat(result.nodeCount()).isEqualTo(expectedNodeCount);
170170
assertThat(
171171
GraphStoreCatalog.exists(
172172
user.getUsername(),
@@ -215,7 +215,7 @@ void shouldUseSingleStartNodeRWR(double samplingRatio, long expectedStartNodeCou
215215
RWR
216216
);
217217

218-
assertThat(result.startNodeCount).isEqualTo(expectedStartNodeCount);
218+
assertThat(result.startNodeCount()).isEqualTo(expectedStartNodeCount);
219219

220220
assertThat(
221221
GraphStoreCatalog.exists(
@@ -259,7 +259,7 @@ void shouldUseSingleStartNodeCNARW(double samplingRatio, long expectedStartNodeC
259259
CNARW
260260
);
261261

262-
assertThat(result.startNodeCount).isEqualTo(expectedStartNodeCount);
262+
assertThat(result.startNodeCount()).isEqualTo(expectedStartNodeCount);
263263

264264
assertThat(
265265
GraphStoreCatalog.exists(
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.catalog;
21+
22+
import org.neo4j.gds.applications.graphstorecatalog.RandomWalkSamplingResult;
23+
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
24+
import org.neo4j.procedure.Context;
25+
import org.neo4j.procedure.Description;
26+
import org.neo4j.procedure.Internal;
27+
import org.neo4j.procedure.Name;
28+
import org.neo4j.procedure.Procedure;
29+
30+
import java.util.Map;
31+
import java.util.stream.Stream;
32+
33+
import static org.neo4j.gds.catalog.GraphCatalogProcedureConstants.RWR_DESCRIPTION;
34+
import static org.neo4j.procedure.Mode.READ;
35+
36+
public class AlphaGraphSampleProc {
37+
@Context
38+
public GraphDataScienceProcedures facade;
39+
40+
@Internal
41+
@Deprecated(forRemoval = true)
42+
@Procedure(name = "gds.alpha.graph.sample.rwr", mode = READ, deprecatedBy = "gds.graph.sample.rwr")
43+
@Description(RWR_DESCRIPTION)
44+
public Stream<RandomWalkSamplingResult> sampleRandomWalkWithRestartsAlpha(
45+
@Name(value = "graphName") String graphName,
46+
@Name(value = "fromGraphName") String fromGraphName,
47+
@Name(value = "configuration", defaultValue = "{}") Map<String, Object> configuration
48+
) {
49+
facade.deprecatedProcedures().called("gds.alpha.graph.sample.rwr");
50+
facade.log()
51+
.warn("Procedure `gds.alpha.graph.sample.rwr` has been deprecated, please use `gds.graph.sample.rwr`.");
52+
return facade.graphCatalog().sampleRandomWalkWithRestarts(graphName, fromGraphName, configuration);
53+
}
54+
}

proc/catalog/src/main/java/org/neo4j/gds/catalog/GraphSampleProc.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
*/
2020
package org.neo4j.gds.catalog;
2121

22-
import org.neo4j.gds.applications.graphstorecatalog.RandomWalkSamplingResult;
2322
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
23+
import org.neo4j.gds.applications.graphstorecatalog.RandomWalkSamplingResult;
2424
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
2525
import org.neo4j.procedure.Context;
2626
import org.neo4j.procedure.Description;
27-
import org.neo4j.procedure.Internal;
2827
import org.neo4j.procedure.Name;
2928
import org.neo4j.procedure.Procedure;
3029

@@ -51,22 +50,6 @@ public Stream<RandomWalkSamplingResult> sampleRandomWalkWithRestarts(
5150
return facade.graphCatalog().sampleRandomWalkWithRestarts(graphName, fromGraphName, configuration);
5251
}
5352

54-
@Internal
55-
@Deprecated(forRemoval = true)
56-
@Procedure(name = "gds.alpha.graph.sample.rwr", mode = READ, deprecatedBy = "gds.graph.sample.rwr")
57-
@Description(RWR_DESCRIPTION)
58-
public Stream<RandomWalkSamplingResult> sampleRandomWalkWithRestartsAlpha(
59-
@Name(value = "graphName") String graphName,
60-
@Name(value = "fromGraphName") String fromGraphName,
61-
@Name(value = "configuration", defaultValue = "{}") Map<String, Object> configuration
62-
) {
63-
facade.deprecatedProcedures().called("gds.alpha.graph.sample.rwr");
64-
facade.log()
65-
.warn("Procedure `gds.alpha.graph.sample.rwr` has been deprecated, please use `gds.graph.sample.rwr`.");
66-
return sampleRandomWalkWithRestarts(graphName, fromGraphName, configuration);
67-
}
68-
69-
7053
@SuppressWarnings("unused")
7154
@Procedure(name = "gds.graph.sample.cnarw", mode = READ)
7255
@Description(CNARW_DESCRIPTION)

subgraph-filtering/src/main/java/org/neo4j/gds/beta/filter/GraphFilterResult.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,6 @@
1919
*/
2020
package org.neo4j.gds.beta.filter;
2121

22-
import org.neo4j.gds.core.loading.GraphProjectResult;
23-
24-
public class GraphFilterResult extends GraphProjectResult {
25-
public final String fromGraphName;
26-
public final String nodeFilter;
27-
public final String relationshipFilter;
28-
29-
public GraphFilterResult(
30-
String graphName,
31-
String fromGraphName,
32-
String nodeFilter,
33-
String relationshipFilter,
34-
long nodeCount,
35-
long relationshipCount,
36-
long projectMillis
37-
) {
38-
super(graphName, nodeCount, relationshipCount, projectMillis);
39-
this.fromGraphName = fromGraphName;
40-
this.nodeFilter = nodeFilter;
41-
this.relationshipFilter = relationshipFilter;
42-
}
22+
public record GraphFilterResult(String graphName, String fromGraphName, String nodeFilter, String relationshipFilter,
23+
long nodeCount, long relationshipCount, long projectMillis) {
4324
}

0 commit comments

Comments
 (0)