Skip to content

Commit 99ac813

Browse files
committed
Replace Map.forEach calls with for-loop on hot path
1 parent 22c1319 commit 99ac813

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

core/src/main/java/org/neo4j/graphalgo/core/utils/export/CompositeRelationshipIterator.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ void forEachRelationship(long sourceId, String relType, InputEntityVisitor visit
7676
// init adjacency cursor
7777
var adjacencyCursor = TransientAdjacencyList.decompressingCursor(cursorCache, offset);
7878
// init property cursors
79-
propertyLists.forEach((propertyKey, propertyList) -> propertyCursorCache.put(
80-
propertyKey,
81-
TransientAdjacencyList.cursor(
82-
propertyCursorCache.get(propertyKey),
83-
propertyOffsets.get(propertyKey).get(sourceId)
84-
)
85-
));
79+
for (var propertyKey : propertyLists.keySet()) {
80+
propertyCursorCache.put(
81+
propertyKey,
82+
TransientAdjacencyList.cursor(
83+
propertyCursorCache.get(propertyKey),
84+
propertyOffsets.get(propertyKey).get(sourceId)
85+
)
86+
);
87+
}
8688

8789
// in-step iteration of adjacency and property cursors
8890
while (adjacencyCursor.hasNextVLong()) {
@@ -91,9 +93,12 @@ void forEachRelationship(long sourceId, String relType, InputEntityVisitor visit
9193
visitor.endId(targetId);
9294
visitor.type(relType);
9395

94-
propertyCursorCache.forEach((propertyKey, propertyCursor) -> {
95-
visitor.property(propertyKey, Double.longBitsToDouble(propertyCursor.nextLong()));
96-
});
96+
for (var propertyKeyAndCursor : propertyCursorCache.entrySet()) {
97+
visitor.property(
98+
propertyKeyAndCursor.getKey(),
99+
Double.longBitsToDouble(propertyKeyAndCursor.getValue().nextLong())
100+
);
101+
}
97102

98103
visitor.endOfEntity();
99104
}

0 commit comments

Comments
 (0)