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


##########
src/iceberg/manifest_reader_internal.h:
##########
@@ -30,14 +32,20 @@ namespace iceberg {
 class ManifestReaderImpl : public ManifestReader {
  public:
   explicit ManifestReaderImpl(std::unique_ptr<Reader> reader,
-                              std::shared_ptr<Schema> schema)
-      : schema_(std::move(schema)), reader_(std::move(reader)) {}
+                              std::shared_ptr<Schema> schema,
+                              std::unique_ptr<InheritableMetadata> 
inheritable_metadata)
+      : schema_(std::move(schema)),
+        reader_(std::move(reader)),
+        inheritable_metadata_(std::move(inheritable_metadata)) {}
+
+  ManifestReaderImpl() = default;

Review Comment:
   Why do we explicitly need this if it is default?



##########
src/iceberg/manifest_reader_internal.h:
##########
@@ -22,6 +22,8 @@
 /// \file iceberg/internal/manifest_reader_internal.h
 /// Reader implementation for manifest list files and manifest files.
 
+#include "iceberg/file_reader.h"

Review Comment:
   ```suggestion
   ```
   
   This is redundant.



##########
src/iceberg/manifest_reader_internal.cc:
##########
@@ -30,6 +30,7 @@
 #include "iceberg/schema.h"
 #include "iceberg/type.h"
 #include "iceberg/util/macros.h"
+#include "iceberg/util/visit_type.h"

Review Comment:
   Can we delete this?



##########
src/iceberg/manifest_reader.cc:
##########
@@ -19,6 +19,7 @@
 
 #include "iceberg/manifest_reader.h"
 
+#include "iceberg/file_reader.h"

Review Comment:
   ```suggestion
   ```



##########
src/iceberg/manifest_reader.cc:
##########
@@ -27,7 +28,33 @@
 
 namespace iceberg {
 
-Result<std::unique_ptr<ManifestReader>> ManifestReader::MakeReader(
+Result<std::unique_ptr<ManifestReader>> ManifestReader::Make(
+    const ManifestFile& manifest, std::shared_ptr<FileIO> file_io,
+    std::shared_ptr<Schema> partition_schema) {
+  // Validate manifest content type - only DATA manifests are supported by 
ManifestReader
+  if (manifest.content != ManifestFile::Content::kData) {
+    return InvalidArgument("Cannot read a delete manifest with a 
ManifestReader: {}",
+                           manifest.manifest_path);
+  }
+

Review Comment:
   ```suggestion
   ```
   
   I don't think so. This function should support both data and delete 
manifests.



##########
src/iceberg/manifest_reader.h:
##########
@@ -27,6 +27,7 @@
 
 #include "iceberg/file_reader.h"
 #include "iceberg/iceberg_export.h"
+#include "iceberg/manifest_list.h"

Review Comment:
   This is redundant. We have forward declaration of `ManifestFile` from 
`iceberg/type_fwd.h` already.



##########
src/iceberg/manifest_reader_internal.h:
##########
@@ -46,6 +54,7 @@ class ManifestListReaderImpl : public ManifestListReader {
   explicit ManifestListReaderImpl(std::unique_ptr<Reader> reader,
                                   std::shared_ptr<Schema> schema)
       : schema_(std::move(schema)), reader_(std::move(reader)) {}
+  ManifestListReaderImpl() = default;

Review Comment:
   ditto



##########
src/iceberg/manifest_reader.cc:
##########
@@ -27,7 +28,33 @@
 
 namespace iceberg {
 
-Result<std::unique_ptr<ManifestReader>> ManifestReader::MakeReader(
+Result<std::unique_ptr<ManifestReader>> ManifestReader::Make(
+    const ManifestFile& manifest, std::shared_ptr<FileIO> file_io,
+    std::shared_ptr<Schema> partition_schema) {
+  // Validate manifest content type - only DATA manifests are supported by 
ManifestReader
+  if (manifest.content != ManifestFile::Content::kData) {
+    return InvalidArgument("Cannot read a delete manifest with a 
ManifestReader: {}",
+                           manifest.manifest_path);
+  }
+
+  auto manifest_entry_schema = 
ManifestEntry::TypeFromPartitionType(partition_schema);
+  auto fields_span = manifest_entry_schema->fields();
+  std::vector<SchemaField> fields(fields_span.begin(), fields_span.end());
+  auto schema = std::make_shared<Schema>(fields);

Review Comment:
   ```suggestion
     auto schema = FromStructType(std::move(*manifest_entry_schema), 
std::nullopt);
   ```
   
   You can use `FromStructType` from `iceberg/schema_internal.h` to simplify 
the conversion.



##########
src/iceberg/inheritable_metadata.h:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+/// \file iceberg/inheritable_metadata.h
+/// Metadata inheritance system for manifest entries.
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+#include <iceberg/result.h>
+
+#include "iceberg/iceberg_export.h"
+#include "iceberg/manifest_entry.h"
+#include "iceberg/manifest_list.h"
+
+namespace iceberg {
+
+/// \brief Interface for applying inheritable metadata to manifest entries.
+///
+/// When manifest entries have null values for certain fields (snapshot_id,
+/// data sequence number, file sequence number), these values should be 
inherited
+/// from the manifest file. This interface provides a way to apply such 
inheritance rules.
+class ICEBERG_EXPORT InheritableMetadata {
+ public:
+  virtual ~InheritableMetadata() = default;
+
+  /// \brief Apply inheritable metadata to a manifest entry.
+  /// \param entry The manifest entry to modify.
+  /// \return The modified manifest entry with inherited metadata applied.
+  virtual Result<ManifestEntry> Apply(ManifestEntry entry) = 0;

Review Comment:
   Do we really want to make a copy for every entry if we just want to update 
some fields of it? Can we change the function signature to update them in-place?



##########
src/iceberg/inheritable_metadata.cc:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/inheritable_metadata.h"
+
+#include <cassert>
+#include <utility>
+
+#include <iceberg/result.h>
+

Review Comment:
   ```suggestion
   
   ```



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