Skip to content

Commit 98a713a

Browse files
Correctly initialize cursor when using single
1 parent a30f222 commit 98a713a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

cypher/api/storage-engine-adapter/src/main/java/org/neo4j/gds/compat/AbstractInMemoryRelationshipScanCursor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ public void scan() {
4242
@Override
4343
public void single(long reference) {
4444
reset();
45+
setId(reference - 1);
4546
this.selection = RelationshipSelection.ALL_RELATIONSHIPS;
4647

4748
graphStore.relationshipIds().resolveRelationshipId(reference, (nodeId, offset, context) -> {
4849
this.sourceId = nodeId;
49-
setType(tokenHolders.relationshipTypeTokens().getIdByName(context.relationshipType().name));
50+
findContextAndInitializeCursor(context);
5051

5152
for (long i = 0; i < offset; i++) {
5253
next();

cypher/api/storage-engine-adapter/src/main/java/org/neo4j/gds/storageengine/InMemoryRelationshipCursor.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,23 @@ private boolean progressToNextContext() {
182182
return progressToNextContext();
183183
}
184184

185+
initializeCursorForContext(context);
186+
187+
setId(relationshipTypeOffset + context.offsets().get(sourceId) - 1);
188+
189+
return true;
190+
}
191+
192+
protected void findContextAndInitializeCursor(RelationshipIds.RelationshipIdContext context) {
193+
for (int i = 0; i < relationshipIdContexts.size(); i++) {
194+
if (relationshipIdContexts.get(i) == context) {
195+
this.relationshipContextIndex = i;
196+
initializeCursorForContext(context);
197+
}
198+
}
199+
}
200+
201+
private void initializeCursorForContext(RelationshipIds.RelationshipIdContext context) {
185202
setType(context.relationshipTypeId());
186203

187204
// initialize the adjacency cursor
@@ -195,11 +212,7 @@ private boolean progressToNextContext() {
195212
this.propertyCursors = propertyCursorCache.get(relationshipContextIndex);
196213
var adjacencyProperties = context.adjacencyProperties();
197214
for (int i = 0; i < propertyCursors.length; i++) {
198-
adjacencyProperties[i].propertyCursor(propertyCursors[i], this.sourceId);
215+
adjacencyProperties[i].propertyCursor(propertyCursors[i], this.sourceId);
199216
}
200-
201-
setId(relationshipTypeOffset + context.offsets().get(sourceId) - 1);
202-
203-
return true;
204217
}
205218
}

0 commit comments

Comments
 (0)