edponce commented on a change in pull request #12147:
URL: https://github.com/apache/arrow/pull/12147#discussion_r784308269



##########
File path: cpp/src/arrow/table.cc
##########
@@ -612,7 +612,8 @@ Status 
TableBatchReader::ReadNext(std::shared_ptr<RecordBatch>* out) {
   }
 
   // Determine the minimum contiguous slice across all columns
-  int64_t chunksize = std::min(table_.num_rows(), max_chunksize_);
+  int64_t chunksize =
+      std::min(table_.num_rows() - absolute_row_position_, max_chunksize_);

Review comment:
       Sorry, I am not saying to rewrite the logic as such, simply stating that 
conceptually this is what the code is doing now. You have a loop iterating with 
a constant non-unit stride but the total number of iterations is not a multiple 
of the stride, so at the end you are left with an iteration using a smaller 
stride. This remaining iteration is called the "loop remainder" and needs to be 
accounted for with a final statement after the loop.
   
   From my understanding the original bug (the infinite loop) occurred because 
this loop remainder was not accounted for and the exit condition was never met.




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