westonpace commented on code in PR #13138:
URL: https://github.com/apache/arrow/pull/13138#discussion_r886285595
##########
cpp/src/arrow/compute/exec.cc:
##########
@@ -308,16 +308,30 @@ bool ExecBatchIterator::Next(ExecBatch* batch) {
// Now, fill the batch
batch->values.resize(args_.size());
batch->length = iteration_size;
- for (size_t i = 0; i < args_.size(); ++i) {
- if (args_[i].is_scalar()) {
- batch->values[i] = args_[i].scalar();
- } else if (args_[i].is_array()) {
- batch->values[i] = args_[i].array()->Slice(position_, iteration_size);
- } else {
- const ChunkedArray& carr = *args_[i].chunked_array();
- const auto& chunk = carr.chunk(chunk_indexes_[i]);
- batch->values[i] = chunk->data()->Slice(chunk_positions_[i],
iteration_size);
- chunk_positions_[i] += iteration_size;
+
+ if (iteration_size == length_) {
+ ARROW_DCHECK_EQ(position_, 0);
+ for (size_t i = 0; i < args_.size(); ++i) {
+ if (args_[i].kind() == Datum::CHUNKED_ARRAY) {
+ const ChunkedArray& carr = *args_[i].chunked_array();
+ batch->values[i] = Datum(carr.chunk(chunk_indexes_[i])->data());
+ chunk_positions_[i] += iteration_size;
+ } else {
+ batch->values[i] = std::move(args_[i]);
+ }
Review Comment:
```suggestion
if (args_[i].kind() == Datum::CHUNKED_ARRAY) {
chunk_positions_[i] += iteration_size;
}
batch->values[i] = std::move(args_[i]);
```
I'm not entirely certain this is correct but if `iteration_size == length_`
I think that means you are guaranteed that any chunked arrays are a single
chunk (or at least, there is only one non-zero size chunk) and so you are
consuming it all at once. I'm not even sure you need to update
`chunk_positions_[i]`.
--
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]