AMashenkov commented on a change in pull request #9081:
URL: https://github.com/apache/ignite/pull/9081#discussion_r655454330



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java
##########
@@ -146,40 +137,50 @@ public GridCacheQueryBean query() {
     /**
      * @return If fields query.
      */
-    boolean fields() {
+    public boolean fields() {
         return false;
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean onDone(Collection<R> res, Throwable err) {
-        cctx.time().removeTimeoutObject(this);
-
-        return super.onDone(res, err);
-    }
-
     /** {@inheritDoc} */
     @Override public R next() {
         try {
-            R next = unmaskNull(internalIterator().next());
+            if (!limitDisabled && cnt == capacity)
+                return null;
 
-            cnt.decrementAndGet();
+            checkError();
+
+            R next = null;
+
+            if (reducer().hasNext()) {
+                next = unmaskNull(reducer().next());
+
+                if (!limitDisabled) {
+                    cnt++;
+
+                    // Exceed limit, stop page loading and cancel queries.
+                    if (cnt == capacity)
+                        cancel();
+                }
+            }
+
+            checkError();
 
             return next;
         }
-        catch (NoSuchElementException ignored) {
-            return null;
-        }
         catch (IgniteCheckedException e) {
             throw CU.convertToCacheException(e);
         }
     }
 
+    /** @return Cache query results reducer. */
+    protected abstract CacheQueryReducer<R> reducer();
+
     /**
-     * Waits for the first page to be received from remote node(s), if any.
+     * Waits for the first item to be received from remote node(s), if any.
      *
      * @throws IgniteCheckedException If query execution failed with an error.
      */
-    public abstract void awaitFirstPage() throws IgniteCheckedException;
+    public abstract void awaitFirstItem() throws IgniteCheckedException;

Review comment:
       Maybe awaitFirstItemAvailable() will be better.
   Actually, we wait here not for the first item/page from remote, but the 
first item available after the reduction applied.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to