wgtmac commented on code in PR #33656:
URL: https://github.com/apache/arrow/pull/33656#discussion_r1070251769


##########
cpp/src/parquet/arrow/writer.cc:
##########
@@ -403,17 +410,31 @@ class FileWriterImpl : public FileWriter {
     }
 
     auto WriteBatch = [&](int64_t offset, int64_t size) {
+      std::vector<std::unique_ptr<ArrowColumnWriterV2>> writers;
+
       int column_index_start = 0;
       for (int i = 0; i < batch.num_columns(); i++) {
-        ChunkedArray chunkedArray(batch.column(i));
+        ChunkedArray chunkedArray{batch.column(i)};

Review Comment:
   If the optimization is aggressive, it may be true. I am also suspecting this 
is the root cause of test failure.



##########
cpp/src/parquet/arrow/writer.cc:
##########
@@ -333,7 +340,7 @@ class FileWriterImpl : public FileWriter {
           std::unique_ptr<ArrowColumnWriterV2> writer,
           ArrowColumnWriterV2::Make(*data, offset, size, schema_manifest_,
                                     row_group_writer_));
-      return writer->Write(&column_write_context_);
+      return writer->Write(&column_write_context_.back());

Review Comment:
   Then it is invalid to call `WriteColumnChunk`. Maybe I need to add a check 
to protect it.



##########
cpp/src/parquet/properties.h:
##########
@@ -843,6 +863,9 @@ class PARQUET_EXPORT ArrowWriterProperties {
     bool store_schema_;
     bool compliant_nested_types_;
     EngineVersion engine_version_;
+
+    bool use_threads_;
+    ::arrow::internal::Executor* executor_;

Review Comment:
   No, the default value is nullptr and executor created by 
`::arrow::internal::GetCpuThreadPool()` will be used by default. If this is not 
a good idea, I can set the default value to 
`::arrow::internal::GetCpuThreadPool()` to make follow-up use much simpler.



##########
cpp/src/parquet/arrow/writer.cc:
##########
@@ -403,17 +410,31 @@ class FileWriterImpl : public FileWriter {
     }
 
     auto WriteBatch = [&](int64_t offset, int64_t size) {
+      std::vector<std::unique_ptr<ArrowColumnWriterV2>> writers;
+
       int column_index_start = 0;
       for (int i = 0; i < batch.num_columns(); i++) {
-        ChunkedArray chunkedArray(batch.column(i));
+        ChunkedArray chunkedArray{batch.column(i)};
         ARROW_ASSIGN_OR_RAISE(
             std::unique_ptr<ArrowColumnWriterV2> writer,
             ArrowColumnWriterV2::Make(chunkedArray, offset, size, 
schema_manifest_,
                                       row_group_writer_, column_index_start));
-        RETURN_NOT_OK(writer->Write(&column_write_context_));
         column_index_start += writer->leaf_count();
+        writers.emplace_back(std::move(writer));

Review Comment:
   Agreed. Let me refactor it to share common logic and avoid unnecessary 
vector creation.



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