cyb70289 commented on a change in pull request #12574: URL: https://github.com/apache/arrow/pull/12574#discussion_r820339520
########## File path: cpp/src/arrow/csv/writer.cc ########## @@ -572,33 +558,34 @@ class CSVWriterImpl : public ipc::RecordBatchWriter { } // Calculate cumulative offsets for each row (including delimiters). // ',' * num_columns - 1(last column doesn't have ,) + eol - int32_t delimiters_length = + const int32_t delimiters_length = static_cast<int32_t>(batch.num_columns() - 1 + options_.eol.size()); - offsets_[0] += delimiters_length; - for (int64_t row = 1; row < batch.num_rows(); row++) { - offsets_[row] += offsets_[row - 1] + delimiters_length; + int64_t last_row_length = offsets_[0] + delimiters_length; + offsets_[0] = 0; + for (size_t row = 1; row < offsets_.size(); ++row) { + const int64_t this_row_length = offsets_[row] + delimiters_length; + offsets_[row] = offsets_[row - 1] + last_row_length; + last_row_length = this_row_length; Review comment: `offsets_[i]` was the length of row `i` before the conversion. After the conversion, `offsets_[i]` is the start position of row `i` in output buffer. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org