shangxinli commented on code in PR #354:
URL: https://github.com/apache/iceberg-cpp/pull/354#discussion_r2570250645


##########
src/iceberg/partition_summary.cc:
##########
@@ -74,16 +75,16 @@ PartitionSummary::PartitionSummary(const StructType& 
partition_type) {
   }
 }
 
-Status PartitionSummary::Update(const std::vector<Literal>& partition_values) {
-  if (partition_values.size() != field_stats_.size()) [[unlikely]] {
+Status PartitionSummary::Update(const PartitionValues& partition_values) {
+  if (partition_values.num_fields() != field_stats_.size()) [[unlikely]] {
     return InvalidArgument("partition values size {} does not match field 
stats size {}",
-                           partition_values.size(), field_stats_.size());
+                           partition_values.num_fields(), field_stats_.size());
   }
 
-  for (size_t i = 0; i < partition_values.size(); i++) {
+  for (size_t i = 0; i < partition_values.num_fields(); i++) {
     ICEBERG_ASSIGN_OR_RAISE(
         auto literal,
-        partition_values[i].CastTo(
+        partition_values.ValueAt(i)->get().CastTo(

Review Comment:
   ValueAt() returns Result<std::reference_wrapper<const Literal>>, but  we're 
using ->get() directly. Since ValueAt() can return an error (e.g., if the index 
is out of bounds), we should check the Result before accessing the value. 
Otherwise, we might hit undefined behavior at runtime. We can something like: 
    ICEBERG_ASSIGN_OR_RAISE(auto partition_value_ref, 
partition_values.ValueAt(i));
     const auto& partition_value = partition_value_ref.get();



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