Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit d91d6ea

Browse files
mknblchjexp
authored andcommitted
added concurrency settings to ProcedureConfig + ProcedureConstants (#173)
1 parent 77cf0f0 commit d91d6ea

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

algo/src/main/java/org/neo4j/graphalgo/AllShortestPathsProc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Stream<AllShortestPaths.Result> allShortestPathsStream(
5454
.withExecutorService(Pools.DEFAULT)
5555
.load(configuration.getGraphImpl());
5656

57-
return new AllShortestPaths(graph, Pools.DEFAULT, configuration.get("concurrency", 1))
57+
return new AllShortestPaths(graph, Pools.DEFAULT, configuration.getConcurrency())
5858
.resultStream();
5959
}
6060
}

core/src/main/java/org/neo4j/graphalgo/core/ProcedureConfiguration.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public ProcedureConfiguration overrideRelationshipTypeOrQuery(String relationshi
5353

5454
/**
5555
* override property param
56-
* @param property the property
56+
* @param weightProperty the property
5757
* @return self
5858
*/
5959
public ProcedureConfiguration overrideProperty(String weightProperty) {
@@ -129,6 +129,14 @@ public int getBatchSize(int defaultValue) {
129129
return getNumber(ProcedureConstants.BATCH_SIZE_PARAM, defaultValue).intValue();
130130
}
131131

132+
public int getConcurrency(int defaultValue) {
133+
return getNumber(ProcedureConstants.CONCURRENCY, defaultValue).intValue();
134+
}
135+
136+
public int getConcurrency() {
137+
return getConcurrency(ProcedureConstants.DEFAULT_CONCURRENCY);
138+
}
139+
132140
public String getDirectionName() {
133141
return get(ProcedureConstants.DIRECTION, ProcedureConstants.DIRECTION_DEFAULT);
134142
}

core/src/main/java/org/neo4j/graphalgo/core/ProcedureConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ public class ProcedureConstants {
4242
public static final String GRAPH_IMPL_PARAM = "graph";
4343

4444
public static final String DEFAULT_GRAPH_IMPL = "heavy";
45+
46+
public static final String CONCURRENCY = "concurrency";
47+
48+
public static final int DEFAULT_CONCURRENCY = Runtime.getRuntime().availableProcessors() / 2;
4549
}

tests/src/test/java/org/neo4j/graphalgo/algo/AllShortestPathsProcTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* S->X: {S,G,H,I,X}:8, {S,D,E,F,X}:12, {S,A,B,C,X}:20
4040
*/
41-
@RunWith(Parameterized.class)
41+
//@RunWith(Parameterized.class)
4242
public final class AllShortestPathsProcTest {
4343

4444
private static GraphDatabaseAPI api;
@@ -101,16 +101,15 @@ public static void shutdownGraph() throws Exception {
101101
api.shutdown();
102102
}
103103

104-
@Parameterized.Parameters(name = "{0}")
105-
public static Collection<Object[]> data() {
106-
return Arrays.asList(
107-
new Object[]{"Heavy"},
108-
new Object[]{"Light"}
109-
);
110-
}
104+
// @Parameterized.Parameters(name = "{0}")
105+
// public static Collection<Object[]> data() {
106+
// return Arrays.asList(
107+
// new Object[]{"Heavy"}, new Object[]{"Light"}
108+
// );
109+
// }
111110

112-
@Parameterized.Parameter
113-
public String graphImpl;
111+
// @Parameterized.Parameter
112+
public String graphImpl = "Heavy";
114113

115114
@Test
116115
public void testResultStream() throws Exception {

0 commit comments

Comments
 (0)