Skip to content

Commit 53c2465

Browse files
Suggest fix
1 parent d6d5b55 commit 53c2465

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

core/src/main/java/org/neo4j/gds/core/huge/NodeFilteredAdjacencyCursor.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ public class NodeFilteredAdjacencyCursor implements AdjacencyCursor {
2929
private final AdjacencyCursor innerCursor;
3030
private final FilteredIdMap idMap;
3131

32-
private long nextLongValue;
32+
private long currentLongValue;
3333

3434
NodeFilteredAdjacencyCursor(AdjacencyCursor innerCursor, FilteredIdMap idMap) {
3535
this.innerCursor = innerCursor;
3636
this.idMap = idMap;
3737

38-
this.nextLongValue = -1L;
38+
this.currentLongValue = -1L;
3939
}
4040

4141
@Override
4242
public void init(long index, int degree) {
4343
innerCursor.init(index, degree);
44+
hasNextVLong();
4445
}
4546

4647
@Override
@@ -59,23 +60,25 @@ public boolean hasNextVLong() {
5960
innerCursor.nextVLong();
6061
return hasNextVLong();
6162
}
62-
this.nextLongValue = idMap.toFilteredNodeId(innerNextLong);
63+
this.currentLongValue = idMap.toFilteredNodeId(innerNextLong);
6364
return true;
6465
}
6566
return false;
6667
}
6768

6869
@Override
6970
public long nextVLong() {
71+
var valueAtReturn = this.currentLongValue;
7072
if (innerCursor.hasNextVLong()) {
7173
innerCursor.nextVLong();
7274
}
73-
return this.nextLongValue;
75+
hasNextVLong();
76+
return valueAtReturn;
7477
}
7578

7679
@Override
7780
public long peekVLong() {
78-
return this.nextLongValue;
81+
return this.currentLongValue;
7982
}
8083

8184
@Override
@@ -88,26 +91,26 @@ public int remaining() {
8891

8992
@Override
9093
public long skipUntil(long nodeId) {
91-
while (nextLongValue <= nodeId) {
94+
while (currentLongValue <= nodeId) {
9295
if (hasNextVLong()) {
9396
nextVLong();
9497
} else {
9598
return AdjacencyCursor.NOT_FOUND;
9699
}
97100
}
98-
return nextLongValue;
101+
return currentLongValue;
99102
}
100103

101104
@Override
102105
public long advance(long nodeId) {
103-
while (nextLongValue < nodeId) {
106+
while (currentLongValue < nodeId) {
104107
if (hasNextVLong()) {
105108
nextVLong();
106109
} else {
107110
return AdjacencyCursor.NOT_FOUND;
108111
}
109112
}
110-
return nextLongValue;
113+
return currentLongValue;
111114
}
112115

113116
@Override
@@ -117,7 +120,7 @@ public long advanceBy(int n) {
117120
while (hasNextVLong()) {
118121
nextVLong();
119122
if (n-- == 0) {
120-
return nextLongValue;
123+
return currentLongValue;
121124
}
122125
}
123126
return NOT_FOUND;

0 commit comments

Comments
 (0)