xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197719492


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1408,8 +1408,12 @@ private void scanBatch(int n) {
 
                     if (binaryRows.size() < n) {
                         cancel();
-                    } else if 
(requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size())) > 0) {
-                        scanBatch(Math.min(n, INTERNAL_BATCH_SIZE));
+                    } else {
+                        long remaining = 
requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size()));
+
+                        if (remaining > 0) {
+                            scanBatch((int) Math.min(remaining, 
INTERNAL_BATCH_SIZE));

Review Comment:
   No, I don't think so, RequestItemsCnt represents the number of requested 
rows left.
   
   For example, user expects 513 rows total.:
   ```
   request(1)  // requestedItemsCnt=1, then call scanBatch(1)
   request(512) // just set requestedItemsCnt=513, don't call scanBatch(512)
   ```
   When the first scanBatch (n = 1) completes we have
   ```
   n = 1 (still)
   remaining = requestedItemsCnt - processed = 512
   ```
   then (with your suggestion) we will repeat it with n = 1 
   ```
   scanBatch(Math.min(n, remaining)) = scanBatch(Math.min(1, 512)) = 
scanBatch(1)
   ```
   
   In other worlds we'll do
   ```
   while (remaining-- > 0)
    scanBatch(n=1)
   ```
   instead of single `scanBatch(512)`
   
   



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

Reply via email to