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


##########
cpp/src/parquet/metadata.cc:
##########
@@ -132,6 +132,31 @@ std::shared_ptr<Statistics> MakeColumnStats(const 
format::ColumnMetaData& meta_d
   throw ParquetException("Can't decode page statistics for selected column 
type");
 }
 
+template <typename Metadata>
+std::shared_ptr<KeyValueMetadata> CopyKeyValueMetadata(const Metadata& source) 
{
+  std::shared_ptr<KeyValueMetadata> metadata = nullptr;
+  if (source.__isset.key_value_metadata) {
+    metadata = std::make_shared<KeyValueMetadata>();
+    for (const auto& it : source.key_value_metadata) {
+      metadata->Append(it.key, it.value);
+    }
+  }
+  return metadata;
+}
+
+template <typename Metadata>
+void ToThriftKeyValueMetadata(Metadata& metadata, const KeyValueMetadata& 
source) {
+  std::vector<format::KeyValue> key_value_metadata;
+  key_value_metadata.reserve(static_cast<size_t>(source.size()));
+  for (int64_t i = 0; i < source.size(); ++i) {
+    format::KeyValue kv_pair;
+    kv_pair.__set_key(source.key(i));
+    kv_pair.__set_value(source.value(i));
+    key_value_metadata.emplace_back(kv_pair);
+  }
+  metadata.__set_key_value_metadata(key_value_metadata);

Review Comment:
   Aha sorry for misleading, previously I suggest not moving element in member 
when building ( `metadata_` ). We can applying move for temporary thrift objects



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