shuliga commented on a change in pull request #6917: IGNITE-12189 
Implementation correct limit for TextQuery
URL: https://github.com/apache/ignite/pull/6917#discussion_r337552122
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java
 ##########
 @@ -327,9 +331,15 @@ protected void onNodeLeft(UUID evtNodeId) {
     protected void enqueue(Collection<?> col) {
         assert Thread.holdsLock(this);
 
-        queue.add((Collection<R>)col);
-
-        cnt.addAndGet(col.size());
+        if(limitCnt <= 0 || limitCnt >= col.size()) {
+            queue.add((Collection<R>)col);
+            cnt.addAndGet(col.size());
+            limitCnt -= col.size();
+        } else {
+            int toAdd = limitCnt;
 
 Review comment:
   I this case let us set 'limitCnt'=0 as soon as we have first node's portion 
that fulfills our limit. But arrived data from 2nd node still makes enqueue() 
to be called one more time. For 'limitCnt' =0 the first condition will fire as 
if it is no-limit case (limit<=0 is treated as no limit) what is not good 
specially here. So we need to add kind a 'limitReached' flag, set it in 'else' 
block and check at the method entry. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to