mapleFU commented on code in PR #181:
URL: https://github.com/apache/iceberg-cpp/pull/181#discussion_r2296175087


##########
src/iceberg/row/manifest_wrapper.h:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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/manifest_wrapper.h
+/// Wrapper classes for manifest-related data structures that implement
+/// StructLike, ArrayLike, and MapLike interfaces for unified data access.
+
+#include <functional>

Review Comment:
   Why this is included?



##########
src/iceberg/row/manifest_wrapper.cc:
##########
@@ -0,0 +1,166 @@
+/*
+ * 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/row/manifest_wrapper.h"
+
+#include "iceberg/manifest_reader_internal.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+namespace {
+template <typename T>
+  requires std::is_same_v<T, std::vector<uint8_t>> || std::is_same_v<T, 
std::string>
+std::string_view ToView(const T& value) {
+  return {reinterpret_cast<const char*>(value.data()), value.size()};  // 
NOLINT
+}
+
+}  // namespace
+
+Result<Scalar> PartitionFieldSummaryStructLike::GetField(size_t pos) const {
+  if (pos >= num_fields()) {
+    return InvalidArgument("Invalid partition field summary index: {}", pos);
+  }
+  switch (pos) {
+    case 0:
+      return summary_.get().contains_null;
+    case 1: {
+      if (summary_.get().contains_nan.has_value()) {
+        return summary_.get().contains_nan.value();
+      }
+      return {};
+    }
+    case 2: {
+      if (summary_.get().lower_bound.has_value()) {
+        return ToView(summary_.get().lower_bound.value());
+      }
+      return {};
+    }
+    case 3: {
+      if (summary_.get().upper_bound.has_value()) {
+        return ToView(summary_.get().upper_bound.value());
+      }
+      return {};
+    }
+    default:
+      return InvalidArgument("Invalid partition field summary index: {}", pos);
+  }
+}
+
+Result<Scalar> PartitionFieldSummaryArrayLike::GetElement(size_t pos) const {
+  if (pos >= size()) {
+    return InvalidArgument("Invalid partition field summary index: {}", pos);
+  }
+  if (summary_ == nullptr) {
+    summary_ = 
std::make_shared<PartitionFieldSummaryStructLike>(summaries_.get()[pos]);
+  } else {
+    summary_->Reset(summaries_.get()[pos]);
+  }
+  return summary_;
+}
+
+Result<Scalar> ManifestFileStructLike::GetField(size_t pos) const {
+  if (pos >= num_fields()) {
+    return InvalidArgument("Invalid manifest file field index: {}", pos);
+  }
+  ICEBERG_ASSIGN_OR_RAISE(auto field,
+                          
ManifestFileFieldFromIndex(static_cast<int32_t>(pos)));
+  const auto& manifest_file = manifest_file_.get();
+  switch (field) {
+    case ManifestFileField::kManifestPath:
+      return ToView(manifest_file.manifest_path);
+    case ManifestFileField::kManifestLength:
+      return manifest_file.manifest_length;
+    case ManifestFileField::kPartitionSpecId:
+      return manifest_file.partition_spec_id;
+    case ManifestFileField::kContent:
+      return static_cast<int32_t>(manifest_file.content);
+    case ManifestFileField::kSequenceNumber:
+      return manifest_file.sequence_number;
+    case ManifestFileField::kMinSequenceNumber:
+      return manifest_file.min_sequence_number;
+    case ManifestFileField::kAddedSnapshotId:
+      return manifest_file.added_snapshot_id;
+    case ManifestFileField::kAddedFilesCount: {
+      if (manifest_file.added_files_count.has_value()) {

Review Comment:
   Wraps a FromOptional?



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