alamb commented on code in PR #7786:
URL: https://github.com/apache/arrow-rs/pull/7786#discussion_r2167890060


##########
parquet-variant/src/builder.rs:
##########
@@ -597,29 +597,31 @@ impl<'a, 'b> ObjectBuilder<'a, 'b> {
         }
     }
 
+    fn check_pending_field(&mut self) {

Review Comment:
   I wonder if there is some sort of RAAI mechanism we can use to ensure that 
the pending field is completed automatically when the child `ListBuilder` or 
`ObjectBuilder` is dropped
   
   That way the compiler can ensure this type of bug is not possible
   
   Something like
   ```rust
   /// If this is a builder for a nested object or list, on `Drop` this object 
will finish the
   /// in progress field for the parent
   enum PendingParent {
   ...
   }
   
   impl Drop for PendingParent {
    List(...),
   Object {
     field_name: &str,
     offset: usize
    }
   }
   ```
   
   Then  we could create a field on the builder like this
   ```rust
   struct ObjectBuilder {
   ...
     pending: Option<PendingParent>,
   }
    ```
   
   I think the biggest challenge would be sorting out the type lifetimes
   



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