|
45 | 45 | import org.neo4j.gds.core.write.NativeNodePropertiesExporterBuilder; |
46 | 46 | import org.neo4j.gds.core.write.NativeRelationshipExporterBuilder; |
47 | 47 | import org.neo4j.gds.core.write.NativeRelationshipStreamExporterBuilder; |
48 | | -import org.neo4j.gds.executor.ComputationResult; |
49 | 48 | import org.neo4j.gds.transaction.TransactionContext; |
50 | 49 | import org.neo4j.gds.utils.StringJoining; |
51 | 50 | import org.neo4j.graphdb.GraphDatabaseService; |
@@ -192,37 +191,22 @@ public void remove(String username, JobId jobId) { |
192 | 191 | default void shouldUnregisterTaskAfterComputation() { |
193 | 192 | var taskStore = new InvocationCountingTaskStore(); |
194 | 193 |
|
195 | | - String loadedGraphName = "loadedGraph"; |
196 | | - GraphProjectConfig graphProjectConfig = withNameAndRelationshipProjections( |
| 194 | + var loadedGraphName = "loadedGraph"; |
| 195 | + var graphProjectConfig = withNameAndRelationshipProjections( |
197 | 196 | "", |
198 | 197 | loadedGraphName, |
199 | 198 | relationshipProjections() |
200 | 199 | ); |
201 | | - applyOnProcedure(proc -> { |
202 | | - proc.taskRegistryFactory = jobId -> new TaskRegistry("", taskStore, jobId); |
203 | 200 |
|
204 | | - GraphStore graphStore = graphLoader(graphProjectConfig).graphStore(); |
205 | | - GraphStoreCatalog.set( |
206 | | - graphProjectConfig, |
207 | | - graphStore |
208 | | - ); |
209 | | - Map<String, Object> configMap = createMinimalConfig(CypherMapWrapper.empty()).toMap(); |
210 | | - ComputationResult<?, RESULT, CONFIG> computationResult1 = proc.compute( |
211 | | - loadedGraphName, |
212 | | - configMap, |
213 | | - releaseAlgorithm(), |
214 | | - true |
215 | | - ); |
| 201 | + GraphStoreCatalog.set( |
| 202 | + graphProjectConfig, |
| 203 | + graphLoader(graphProjectConfig).graphStore() |
| 204 | + ); |
216 | 205 |
|
217 | | - ComputationResult<?, RESULT, CONFIG> computationResult2 = proc.compute( |
218 | | - loadedGraphName, |
219 | | - configMap, |
220 | | - releaseAlgorithm(), |
221 | | - true |
222 | | - ); |
| 206 | + applyOnProcedure(proc -> { |
| 207 | + proc.taskRegistryFactory = jobId -> new TaskRegistry("", taskStore, jobId); |
223 | 208 |
|
224 | | - // trigger consumption of stream return values |
225 | | - assertResultEquals(computationResult1.result(), computationResult2.result()); |
| 209 | + runTwiceAndAssertEqualResult(loadedGraphName, proc); |
226 | 210 |
|
227 | 211 | assertThat(taskStore.taskStream()) |
228 | 212 | .withFailMessage(() -> formatWithLocale( |
@@ -282,32 +266,36 @@ default boolean releaseAlgorithm() { |
282 | 266 | @ParameterizedTest |
283 | 267 | @ValueSource(booleans = {true, false}) |
284 | 268 | default void testRunMultipleTimesOnLoadedGraph(boolean cypherProjection) { |
285 | | - String loadedGraphName = "loadedGraph"; |
286 | | - GraphProjectConfig graphProjectConfig = cypherProjection |
| 269 | + var loadedGraphName = "loadedGraph"; |
| 270 | + var graphProjectConfig = cypherProjection |
287 | 271 | ? emptyWithNameCypher(TEST_USERNAME, loadedGraphName) |
288 | | - : withNameAndRelationshipProjections(TEST_USERNAME, loadedGraphName, relationshipProjections()); |
289 | | - |
290 | | - applyOnProcedure((proc) -> { |
291 | | - GraphStoreCatalog.set( |
292 | | - graphProjectConfig, |
293 | | - graphLoader(graphProjectConfig).graphStore() |
294 | | - ); |
295 | | - Map<String, Object> configMap = createMinimalConfig(CypherMapWrapper.empty()).toMap(); |
296 | | - ComputationResult<?, RESULT, CONFIG> resultRun1 = proc.compute( |
297 | | - loadedGraphName, |
298 | | - configMap, |
299 | | - releaseAlgorithm(), |
300 | | - true |
301 | | - ); |
302 | | - ComputationResult<?, RESULT, CONFIG> resultRun2 = proc.compute( |
303 | | - loadedGraphName, |
304 | | - configMap, |
305 | | - releaseAlgorithm(), |
306 | | - true |
| 272 | + : withNameAndRelationshipProjections(TEST_USERNAME, loadedGraphName, relationshipProjections() |
307 | 273 | ); |
308 | 274 |
|
309 | | - assertResultEquals(resultRun1.result(), resultRun2.result()); |
310 | | - }); |
| 275 | + GraphStoreCatalog.set( |
| 276 | + graphProjectConfig, |
| 277 | + graphLoader(graphProjectConfig).graphStore() |
| 278 | + ); |
| 279 | + |
| 280 | + applyOnProcedure(proc -> runTwiceAndAssertEqualResult(loadedGraphName, proc)); |
| 281 | + } |
| 282 | + |
| 283 | + private void runTwiceAndAssertEqualResult(String loadedGraphName, AlgoBaseProc<ALGORITHM, RESULT, CONFIG, ?> proc) { |
| 284 | + var configMap = createMinimalConfig(CypherMapWrapper.empty()).toMap(); |
| 285 | + var resultRun1 = proc.compute( |
| 286 | + loadedGraphName, |
| 287 | + configMap, |
| 288 | + releaseAlgorithm(), |
| 289 | + true |
| 290 | + ); |
| 291 | + var resultRun2 = proc.compute( |
| 292 | + loadedGraphName, |
| 293 | + configMap, |
| 294 | + releaseAlgorithm(), |
| 295 | + true |
| 296 | + ); |
| 297 | + |
| 298 | + assertResultEquals(resultRun1.result(), resultRun2.result()); |
311 | 299 | } |
312 | 300 |
|
313 | 301 | @Test |
|
0 commit comments