sdf-jkl commented on code in PR #9791:
URL: https://github.com/apache/arrow-rs/pull/9791#discussion_r3140845755
##########
parquet-variant-compute/src/unshred_variant.rs:
##########
@@ -175,12 +174,17 @@ impl<'a> UnshredVariantRowBuilder<'a> {
}
}
- /// Creates a new UnshredVariantRowBuilder from shredding state
- /// Returns None for None/None case - caller decides how to handle based
on context
- fn try_new_opt(shredding_state: BorrowedShreddingState<'a>) ->
Result<Option<Self>> {
- let value = shredding_state.value_field();
- let typed_value = shredding_state.typed_value_field();
- let Some(typed_value) = typed_value else {
+ /// Creates a new UnshredVariantRowBuilder from the `(value, typed_value)`
pair of a shredded
+ /// variant struct. Returns None for the None/None case - caller decides
how to handle based on
+ /// context.
+ fn try_new_opt(inner_struct: &'a StructArray) -> Result<Option<Self>> {
Review Comment:
This is the place where `BorrowedShreddingState` was so useful.
For nested builders (List/Struct) we used to recursively call
`try_new_opt(field_array.try_into()?)`: the `try_into` produced a
`BorrowedShreddingState<'a>` whose `ArrayRef`s were borrowed from the source
`field_array`. The wrapper got consumed, but the `&'a ArrayRef`s inside it
carried `'a` along and could be stored in the builder.
In `ShreddingState` the `ArrayRef`s are owned, so once we call the function
- the `ShreddingState` goes out of scope and the references point to free
memory.
A workaround is using `&StructArray` since it's a reference to the outer
`Array` data.
--
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]