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


##########
parquet-variant/src/builder.rs:
##########
@@ -592,12 +592,16 @@ impl<'a> ObjectBuilder<'a> {
     }
 
     /// Add a field with key and value to the object
-    pub fn append_value<'m, 'd, T: Into<Variant<'m, 'd>>>(&mut self, key: 
&str, value: T) {
+    ///
+    /// Note: when inserting duplicate keys, the new value overwrites the 
previous mapping,
+    /// but the old value remains in the buffer, resulting in a larger variant
+    pub fn insert<'m, 'd, T: Into<Variant<'m, 'd>>>(&mut self, key: &str, 
value: T) {
         let field_id = self.metadata_builder.add_field_name(key);
         let field_start = self.buffer.offset();
+
+        self.fields.insert(field_id, field_start);
+
         self.buffer.append_value(value);

Review Comment:
   ```suggestion
           self.fields.insert(field_id, field_start);
           self.buffer.append_value(value);
   ```
   (the extra whitespace didn't seem very helpful)



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