Skip to content

Commit 3835b93

Browse files
Mats-SXadamnsch
andcommitted
Downcast to NodeEntity to get stable signature
Neo4j 4 and 5 return a different type for the method org.neo4j.graphdb.Node#getRelationships() This causes a bytecode error, because the compiler records the exact type of the method known at compile time. There is no such one method that is the same across the Neo4j versions. Co-authored-by: Adam Schill Collberg <adam.schill.collberg@protonmail.com>
1 parent 5f00108 commit 3835b93

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

alpha/alpha-proc/src/main/java/org/neo4j/gds/linkprediction/NeighborsFinder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.neo4j.graphdb.Node;
2424
import org.neo4j.graphdb.Relationship;
2525
import org.neo4j.graphdb.RelationshipType;
26+
import org.neo4j.kernel.impl.core.NodeEntity;
2627

2728
import java.util.Collections;
2829
import java.util.HashSet;
@@ -57,7 +58,7 @@ public Set<Node> findNeighbors(Node node1, Node node2, RelationshipType relation
5758
public Set<Node> findNeighbors(Node node, RelationshipType relationshipType, Direction direction) {
5859
Set<Node> neighbors = new HashSet<>();
5960

60-
for (Relationship rel : loadRelationships(node, relationshipType, direction)) {
61+
for (Relationship rel : loadRelationships((NodeEntity) node, relationshipType, direction)) {
6162
Node endNode = rel.getOtherNode(node);
6263

6364
if (!endNode.equals(node)) {
@@ -79,15 +80,15 @@ private Direction flipDirection(Direction direction) {
7980
}
8081

8182
private boolean noCommonNeighbors(Node node, RelationshipType relationshipType, Direction direction, Node node2) {
82-
for (Relationship rel : loadRelationships(node, relationshipType, direction)) {
83+
for (Relationship rel : loadRelationships((NodeEntity) node, relationshipType, direction)) {
8384
if (rel.getOtherNode(node).equals(node2)) {
8485
return false;
8586
}
8687
}
8788
return true;
8889
}
8990

90-
private Iterable<Relationship> loadRelationships(Node node, RelationshipType relationshipType, Direction direction) {
91+
private Iterable<Relationship> loadRelationships(NodeEntity node, RelationshipType relationshipType, Direction direction) {
9192
return relationshipType == null
9293
? node.getRelationships(direction)
9394
: node.getRelationships(direction, relationshipType);

0 commit comments

Comments
 (0)