You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2023/04/08 11:41:49 UTC

[GitHub] [arrow] mapleFU commented on a diff in pull request #34889: GH-34888: [C++][Parquet] Writer supports adding extra kv meta

mapleFU commented on code in PR #34889:
URL: https://github.com/apache/arrow/pull/34889#discussion_r1161101486


##########
cpp/src/parquet/file_writer.cc:
##########
@@ -356,6 +355,15 @@ class FileSerializer : public ParquetFileWriter::Contents {
 
   RowGroupWriter* AppendBufferedRowGroup() override { return AppendRowGroup(true); }
 
+  void AddKeyValueMetadata(
+      std::shared_ptr<const KeyValueMetadata> key_value_metadata) override {
+    if (key_value_metadata_ == nullptr) {
+      key_value_metadata_ = std::move(key_value_metadata);
+    } else if (key_value_metadata != nullptr) {
+      key_value_metadata_ = key_value_metadata_->Merge(*key_value_metadata);

Review Comment:
   should we add a DCHECK for `key_value_metadata != nullptr`?



##########
cpp/src/parquet/file_writer.h:
##########
@@ -209,6 +212,12 @@ class PARQUET_EXPORT ParquetFileWriter {
   /// until the next call to AppendRowGroup or AppendBufferedRowGroup or Close.
   RowGroupWriter* AppendBufferedRowGroup();
 
+  /// \brief Add key-value metadata to the file.
+  /// \param[in] key_value_metadata the metadata to add.
+  /// \note This will overwrite any existing metadata with the same key.
+  /// It will not take effect if Close() has been called.

Review Comment:
   Should we throw ex if closed?



##########
cpp/src/parquet/file_writer.cc:
##########
@@ -356,6 +355,15 @@ class FileSerializer : public ParquetFileWriter::Contents {
 
   RowGroupWriter* AppendBufferedRowGroup() override { return AppendRowGroup(true); }
 
+  void AddKeyValueMetadata(
+      std::shared_ptr<const KeyValueMetadata> key_value_metadata) override {

Review Comment:
   Should it better be a `const std::shared_ptr<const KeyValueMetadata>& key_value_metadata`? Because it doesn't force copy everytime



##########
cpp/src/parquet/metadata.h:
##########
@@ -510,24 +510,23 @@ class PARQUET_EXPORT FileMetaDataBuilder {
  public:
   // API convenience to get a MetaData reader
   static std::unique_ptr<FileMetaDataBuilder> Make(
-      const SchemaDescriptor* schema, std::shared_ptr<WriterProperties> props,
-      std::shared_ptr<const KeyValueMetadata> key_value_metadata = NULLPTR);
+      const SchemaDescriptor* schema, std::shared_ptr<WriterProperties> props);

Review Comment:
   Agree



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org