HuaHuaY commented on code in PR #235:
URL: https://github.com/apache/iceberg-cpp/pull/235#discussion_r2371428343
##########
src/iceberg/file_reader.h:
##########
@@ -54,6 +54,9 @@ class ICEBERG_EXPORT Reader {
/// \brief Get the schema of the data.
virtual Result<ArrowSchema> Schema() = 0;
+
+ /// \brief Get the metadata of the file
Review Comment:
```suggestion
/// \brief Get the metadata of the file.
```
##########
src/iceberg/parquet/parquet_reader.cc:
##########
@@ -185,6 +186,31 @@ 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) {
+ metadata_map.insert_or_assign(kv_metadata->key(i),
kv_metadata->value(i));
+ }
Review Comment:
```suggestion
kv_metadata->ToUnorderedMap(&metadata_map);
```
--
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]