mapleFU commented on code in PR #10046:
URL: https://github.com/apache/arrow-rs/pull/10046#discussion_r3565850467
##########
arrow-select/src/interleave.rs:
##########
@@ -513,6 +517,81 @@ fn interleave_list<O: OffsetSizeTrait>(
Ok(Arc::new(list_array))
}
+fn interleave_fixed_size_list(
+ values: &[&dyn Array],
+ indices: &[(usize, usize)],
+ field: &FieldRef,
+ size: i32,
+) -> Result<ArrayRef, ArrowError> {
+ let interleaved = Interleave::<'_, FixedSizeListArray>::new(values,
indices);
+ let capacity = indices.len() * size as usize;
+
+ macro_rules! fsl_primitive_helper {
+ ($t:ty) => {
+ interleave_list_like_primitive_child::<FixedSizeListArray, $t>(
+ &interleaved,
+ indices,
+ capacity,
+ field.data_type(),
+ )
+ };
+ }
+
+ let interleaved_values = downcast_primitive! {
+ field.data_type() => (fsl_primitive_helper),
+ _ => {
+ interleave_list_like_child(&interleaved, indices, capacity)?
+ }
+ };
+
+ let array = FixedSizeListArray::new(field.clone(), size,
interleaved_values, interleaved.nulls);
+ Ok(Arc::new(array))
+}
+
+fn interleave_map(
+ values: &[&dyn Array],
+ indices: &[(usize, usize)],
+ field: &FieldRef,
+ ordered: bool,
+) -> Result<ArrayRef, ArrowError> {
+ let interleaved = Interleave::<'_, MapArray>::new(values, indices);
+
+ let mut capacity = 0usize;
+ let mut offsets = Vec::with_capacity(indices.len() + 1);
Review Comment:
đŸ¤”counting `capacity` and offsets in one loop and pushing? The loop might be:
```
for &(array, row) in indices {
let o = interleaved.arrays[array].value_offsets();
let element_len = (o[row + 1] - o[row]) as usize;
capacity += element_len;
if capacity >= i32::MAX {
return Err(...);
}
builder.push_length(..);
}
```
I'm fine with either approach.
--
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]