Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit 16c422a

Browse files
committed
Fix GraphView property-access for 3.2
1 parent d209bcb commit 16c422a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

core/src/main/java/org/neo4j/graphalgo/core/Kernel.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.neo4j.cursor.Cursor;
66
import org.neo4j.kernel.api.ReadOperations;
77
import org.neo4j.kernel.api.Statement;
8+
import org.neo4j.kernel.api.StatementConstants;
89
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
910
import org.neo4j.kernel.impl.api.store.RelationshipIterator;
1011
import org.neo4j.kernel.impl.locking.Lock;
@@ -360,6 +361,14 @@ public Lock lock() {
360361
return item.lock();
361362
}
362363

364+
public Object propertyValue(int propertyId) {
365+
try {
366+
return propertyId == StatementConstants.NO_SUCH_PROPERTY_KEY ? null : readOperations.nodeGetProperty(item.id(), propertyId);
367+
} catch (EntityNotFoundException e) {
368+
return null;
369+
}
370+
}
371+
363372
PropertyItemCursor cursor = new PropertyItemCursor();
364373
public Cursor<PropertyItem> property(int propertyId) {
365374
try {
@@ -384,6 +393,13 @@ public RelationshipItem(org.neo4j.storageengine.api.RelationshipItem item) {
384393
public RelationshipItem() {
385394
}
386395

396+
public Object propertyValue(int propertyId) {
397+
try {
398+
return propertyId == StatementConstants.NO_SUCH_PROPERTY_KEY ? null : readOperations.relationshipGetProperty(item.id(), propertyId);
399+
} catch (EntityNotFoundException e) {
400+
return null;
401+
}
402+
}
387403
public Cursor<PropertyItem> property(int propertyId) {
388404
try {
389405
cursor.propertyId = propertyId;

core/src/main/java/org/neo4j/graphalgo/core/neo4jview/GraphView.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge;
1818
import org.neo4j.kernel.internal.GraphDatabaseAPI;
1919
import org.neo4j.storageengine.api.NodeItem;
20+
import org.neo4j.storageengine.api.PropertyItem;
2021
import org.neo4j.storageengine.api.RelationshipItem;
2122

2223
import java.util.Arrays;
@@ -91,8 +92,11 @@ public void forEachRelationship(int nodeId, Direction direction, WeightedRelatio
9192
long relId = RawValues.combineIntInt(
9293
(int) item.startNode(),
9394
(int) item.endNode());
94-
double weight = (propertyKey == StatementConstants.NO_SUCH_PROPERTY_KEY) ? propertyDefaultWeight :
95-
((Number) item.property(propertyKey)).doubleValue();
95+
double weight = propertyDefaultWeight;
96+
Object value = item.propertyValue(propertyKey);
97+
if (value instanceof Number) {
98+
weight = ((Number) value).doubleValue();
99+
}
96100

97101
consumer.accept(
98102
nodeId,

0 commit comments

Comments
 (0)