OmBiradar commented on code in PR #50158:
URL: https://github.com/apache/arrow/pull/50158#discussion_r3400134814


##########
cpp/src/parquet/arrow/reader.cc:
##########
@@ -735,10 +735,9 @@ class PARQUET_NO_EXPORT StructReader : public 
ColumnReaderImpl {
   bool IsOrHasRepeatedChild() const final { return has_repeated_child_; }
 
   Status LoadBatch(int64_t records_to_read) override {
-    for (const std::unique_ptr<ColumnReaderImpl>& reader : children_) {
-      RETURN_NOT_OK(reader->LoadBatch(records_to_read));
-    }
-    return Status::OK();
+    return ::arrow::internal::OptionalParallelFor(
+        ctx_->reader_properties->use_threads(), 
static_cast<int>(children_.size()),
+        [&](int i) { return children_[i]->LoadBatch(records_to_read); });

Review Comment:
   ```cpp
   template <class FUNCTION>
   Status OptionalParallelFor(bool use_threads, int num_tasks, FUNCTION&& func,
                              Executor* executor = 
internal::GetCpuThreadPool()) {
     if (use_threads) {
       return ParallelFor(num_tasks, std::forward<FUNCTION>(func), executor);
     } else {
       for (int i = 0; i < num_tasks; ++i) {
         RETURN_NOT_OK(func(i));
       }
       return Status::OK();
     }
   }
   ```
   
   At the end, it's always cast to an `int` so truncating is unavoidable.



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