scovich commented on code in PR #7808:
URL: https://github.com/apache/arrow-rs/pull/7808#discussion_r2176153376


##########
parquet-variant/src/builder.rs:
##########
@@ -643,16 +640,15 @@ impl<'a, 'b> ObjectBuilder<'a, 'b> {
         let num_fields = self.fields.len();
         let is_large = num_fields > u8::MAX as usize;
 
-        let field_ids_by_sorted_field_name = self
-            .metadata_builder
-            .field_name_to_id
-            .iter()
-            .filter_map(|(_, id)| self.fields.contains_key(id).then_some(*id))
-            .collect::<Vec<_>>();
+        self.fields.sort_by(|&field_a_id, _, &field_b_id, _| {
+            let key_a = &self.metadata_builder.field_name(field_a_id as usize);
+            let key_b = &self.metadata_builder.field_name(field_b_id as usize);
+            key_a.cmp(key_b)
+        });
 
-        let max_id = self.fields.keys().last().copied().unwrap_or(0) as usize;
+        let max_id = self.fields.iter().map(|(i, _)| *i).max().unwrap_or(0);

Review Comment:
   What could cause the max id to be different from `fields.len()-1`?



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

Reply via email to