mapleFU commented on code in PR #10025:
URL: https://github.com/apache/arrow-rs/pull/10025#discussion_r3311534958
##########
arrow-select/src/interleave.rs:
##########
@@ -392,29 +463,41 @@ fn interleave_list<O: OffsetSizeTrait>(
);
}
- let mut child_indices = Vec::with_capacity(capacity);
- for (array, row) in indices {
- let list = interleaved.arrays[*array];
- let start = list.value_offsets()[*row].as_usize();
- let end = list.value_offsets()[*row + 1].as_usize();
- child_indices.extend((start..end).map(|i| (*array, i)));
+ // Step 2: build child values.
+ macro_rules! list_primitive_helper {
+ ($t:ty) => {
+ interleave_list_primitive_child::<O, $t>(&interleaved, indices,
capacity)
+ };
}
- let child_arrays: Vec<&dyn Array> = interleaved
- .arrays
- .iter()
- .map(|list| list.values().as_ref())
- .collect();
+ let child_values = downcast_primitive! {
+ // For primitive child types, directly copy typed value slices and
null bit
+ // ranges, avoiding both the intermediate child_indices Vec allocation
and
+ // MutableArrayData's function pointer indirection.
+ field.data_type() => (list_primitive_helper),
+ _ => {
+ // For complex child types (nested lists, structs, views,
dictionaries, etc.),
+ // use recursive interleave to benefit from type-specific
optimizations.
+ let mut child_indices = Vec::with_capacity(capacity);
Review Comment:
This keeps the previous code
--
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]