tmgodinho commented on code in PR #6950:
URL: https://github.com/apache/ignite-3/pull/6950#discussion_r2518658241
##########
modules/core/src/main/java/org/apache/ignite/internal/sql/SyncResultSetAdapter.java:
##########
@@ -107,39 +106,32 @@ public T next() {
private static class IteratorImpl<T> implements Iterator<T> {
private AsyncResultSet<T> curRes;
- private CompletionStage<? extends AsyncResultSet<T>> nextPageStage;
-
private Iterator<T> curPage;
IteratorImpl(AsyncResultSet<T> ars) {
curRes = ars;
-
- advance();
+ curPage = ars.currentPage().iterator();
}
@Override
public boolean hasNext() {
- if (curPage.hasNext()) {
+ if (curPage != null && curPage.hasNext()) {
return true;
- } else if (nextPageStage != null) {
- curRes = sync(nextPageStage.toCompletableFuture());
+ }
+
+ if (curRes == null || !curRes.hasMorePages()) {
+ return false;
+ }
- advance();
+ curRes = sync(curRes.fetchNextPage().toCompletableFuture());
- return curPage.hasNext();
- } else {
+ if (curRes == null) {
return false;
}
- }
- private void advance() {
curPage = curRes.currentPage().iterator();
- if (curRes.hasMorePages()) {
- nextPageStage = curRes.fetchNextPage();
- } else {
- nextPageStage = null;
- }
+ return curPage.hasNext();
Review Comment:
Could you double check if current page can be null??
On line 118 there's a null check, but here there's no null check here. The
code seems very similar though. The current page seems to be init on the
constructor and here the same way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]