scovich commented on code in PR #7865:
URL: https://github.com/apache/arrow-rs/pull/7865#discussion_r2186063515
##########
parquet-variant/src/builder.rs:
##########
@@ -479,20 +572,29 @@ impl VariantBuilder {
self
}
+ // Returns validate_unique_fields because we can no longer reference self
once this method returns.
+ fn parent_state(&mut self) -> (ParentState, bool) {
+ let state = ParentState::Variant {
+ buffer: &mut self.buffer,
+ metadata_builder: &mut self.metadata_builder,
+ };
+ (state, self.validate_unique_fields)
+ }
+
/// Create an [`ListBuilder`] for creating [`Variant::List`] values.
///
/// See the examples on [`VariantBuilder`] for usage.
pub fn new_list(&mut self) -> ListBuilder {
- ListBuilder::new(&mut self.buffer, &mut self.metadata_builder)
- .with_validate_unique_fields(self.validate_unique_fields)
+ let (parent_state, validate_unique_fields) = self.parent_state();
+ ListBuilder::new(parent_state, validate_unique_fields)
Review Comment:
That's what I was doing at first, but it was extra code duplicated at every
call site.
I also tried introducing a `ProvidesParentState` type trait, that the
builder `new` methods could take `&mut impl` of... but that also didn't work
great because `parent_state` for object builder takes a param while this one
does not.
So yeah... the current PR state is the least bad option I thought of.
--
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]