Skip to content

Commit cfd664c

Browse files
Use UserCatalog#remove method to clean graph stores
Co-authored-by: Ioannis Panagiotas <[email protected]>
1 parent aaf8e52 commit cfd664c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

core/src/main/java/org/neo4j/gds/core/loading/GraphStoreCatalog.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,21 @@ public static void setDegreeDistribution(
267267
}
268268

269269
public static void removeAllLoadedGraphs() {
270-
userCatalogs.clear();
270+
userCatalogs.forEach((username, userCatalog) -> {
271+
userCatalog.graphsByName.forEach(((userCatalogKey, graphStoreCatalogEntry) -> {
272+
userCatalog.remove(userCatalogKey, __ -> {}, false);
273+
}));
274+
});
271275
}
272276

273277
public static void removeAllLoadedGraphs(DatabaseId databaseId) {
274-
userCatalogs.forEach((user, userCatalog) -> userCatalog.remove(databaseId.databaseName()));
278+
userCatalogs.forEach((user, userCatalog) -> {
279+
userCatalog.graphsByName.forEach(((userCatalogKey, graphStoreCatalogEntry) -> {
280+
if (databaseId.databaseName().equals(userCatalogKey.databaseName())) {
281+
userCatalog.remove(userCatalogKey, __ -> {}, false);
282+
}
283+
}));
284+
});
275285
}
276286

277287
public static Collection<GraphStoreCatalogEntry> getGraphStores(String username) {
@@ -430,10 +440,6 @@ private boolean remove(
430440
.orElse(Boolean.FALSE);
431441
}
432442

433-
private void remove(String databaseName) {
434-
graphsByName.keySet().removeIf(userCatalogKey -> userCatalogKey.databaseName().equals(databaseName));
435-
}
436-
437443
private Stream<GraphStoreCatalogEntryWithUsername> streamGraphStores(String userName) {
438444
return graphsByName
439445
.values()

0 commit comments

Comments
 (0)