wgtmac commented on code in PR #235:
URL: https://github.com/apache/iceberg-cpp/pull/235#discussion_r2366247869


##########
src/iceberg/avro/avro_reader.cc:
##########
@@ -173,6 +173,27 @@ class AvroReader::Impl {
     return arrow_schema;
   }
 
+  Result<std::unordered_map<std::string, std::string>> Metadata() {
+    if (reader_ == nullptr) {
+      return Invalid("Reader is not opened");
+    }
+
+    const auto& metadata = reader_->metadata();
+
+    std::unordered_map<std::string, std::string> metadata_map;
+    metadata_map.reserve(metadata.size());
+
+    for (const auto& pair : metadata) {
+      auto [it, inserted] = metadata_map.try_emplace(
+          pair.first, std::string(pair.second.begin(), pair.second.end()));
+      if (!inserted) {

Review Comment:
   Same as the other comment.



##########
src/iceberg/parquet/parquet_reader.cc:
##########
@@ -185,6 +186,35 @@ class ParquetReader::Impl {
     return arrow_schema;
   }
 
+  Result<std::unordered_map<std::string, std::string>> Metadata() {
+    if (reader_ == nullptr) {
+      return Invalid("Reader is not opened");
+    }
+
+    auto metadata = reader_->parquet_reader()->metadata();
+    if (!metadata) {
+      return Invalid("Failed to get Parquet file metadata");
+    }
+
+    const auto& kv_metadata = metadata->key_value_metadata();
+    if (!kv_metadata) {
+      return std::unordered_map<std::string, std::string>{};
+    }
+
+    std::unordered_map<std::string, std::string> metadata_map;
+    metadata_map.reserve(kv_metadata->size());
+
+    for (int i = 0; i < kv_metadata->size(); ++i) {
+      auto [it, inserted] =
+          metadata_map.try_emplace(kv_metadata->key(i), kv_metadata->value(i));
+      if (!inserted) {

Review Comment:
   Can we just use the latter to override the former one to avoid error?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to