@@ -77,22 +77,30 @@ static void ensureInverseIndexesExist(
7777 Log log ,
7878 TaskRegistryFactory taskRegistryFactory
7979 ) {
80- relationshipTypes
80+ var relationshipTypesWithoutIndex = relationshipTypes
8181 .stream ()
8282 .filter (relType -> !graphStore .inverseIndexedRelationshipTypes ().contains (relType ))
83- .forEach (relType -> {
84- var inverseConfig = InverseRelationshipsConfigImpl
85- .builder ()
86- .concurrency (concurrency )
87- .relationshipType (relType .name )
88- .build ();
89-
90- var inverseIndex = new InverseRelationshipsAlgorithmFactory ()
91- .build (graphStore , inverseConfig , log , taskRegistryFactory )
92- .compute ();
93-
94- graphStore .addInverseIndex (relType , inverseIndex );
95- });
83+ .map (RelationshipType ::name )
84+ .collect (Collectors .toList ());
85+
86+ if (relationshipTypesWithoutIndex .isEmpty ()) {
87+ return ;
88+ }
89+
90+ var inverseConfig = InverseRelationshipsConfigImpl
91+ .builder ()
92+ .concurrency (concurrency )
93+ .relationshipTypes (relationshipTypesWithoutIndex )
94+ .build ();
95+
96+ new InverseRelationshipsAlgorithmFactory ()
97+ .build (graphStore , inverseConfig , log , taskRegistryFactory )
98+ .compute ()
99+ .forEach ((relationshipType , inverseIndex ) -> graphStore .addInverseIndex (
100+ relationshipType ,
101+ inverseIndex .topology (),
102+ inverseIndex .properties ()
103+ ));
96104 }
97105
98106 static void ensureDirectedRelationships (GraphStore graphStore , Collection <RelationshipType > relationshipTypes ) {
0 commit comments