pavlukhin commented on a change in pull request #6917: IGNITE-12189 
Implementation correct limit for TextQuery

 File path: 
 @@ -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;
+            queue.add(new ArrayList(col).subList(0, toAdd));
 Review comment:
   Unfortunately it is a common practice in Ignite. We do not have cheap 
performance measurement feedback loop, consequently we are trying to use faster 
approaches but possibly sacrificing code simplicity. There were a lot of cases 
from a real practice where a single "innocent" code line (not lock and not 
system call) caused visible performance drop.
   Also I can thing about another option. Apparently a collection coming to 
`enqueue` method is always a `List`. We can try to do a refactoring and change 
an argument type to `List`. Then `List.sublist` method could be used directly. 
Possibly, it deserves a separate ticket. What do you think?

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:

With regards,
Apache Git Services

Reply via email to