Copilot commented on code in PR #50158:
URL: https://github.com/apache/arrow/pull/50158#discussion_r3396204823
##########
cpp/src/parquet/arrow/reader.cc:
##########
@@ -825,10 +824,17 @@ Status StructReader::BuildArray(int64_t
length_upper_bound,
END_PARQUET_CATCH_EXCEPTIONS
// Gather children arrays and def levels
- for (auto& child : children_) {
- std::shared_ptr<ChunkedArray> field;
- RETURN_NOT_OK(child->BuildArray(validity_io.values_read, &field));
- ARROW_ASSIGN_OR_RAISE(std::shared_ptr<ArrayData> array_data,
ChunksToSingle(*field));
+ const int num_children = static_cast<int>(children_.size());
Review Comment:
`children_.size()` is `size_t`, and narrowing it via `static_cast<int>` can
silently truncate for large values. Prefer using a checked/narrowing-safe cast
helper (e.g., Arrow's checked_cast/narrow_cast) or keep the task count in a
wider integer type if supported by `OptionalParallelFor` to avoid potential
overflow/truncation.
##########
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:
`children_.size()` is `size_t`, and narrowing it via `static_cast<int>` can
silently truncate for large values. Prefer using a checked/narrowing-safe cast
helper (e.g., Arrow's checked_cast/narrow_cast) or keep the task count in a
wider integer type if supported by `OptionalParallelFor` to avoid potential
overflow/truncation.
--
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]