Fallback implementation of interleave using [`MutableArrayData`]
(
values: &[&dyn Array],
indices: &[(usize, usize)],
)
| 594 | |
| 595 | /// Fallback implementation of interleave using [`MutableArrayData`] |
| 596 | fn interleave_fallback( |
| 597 | values: &[&dyn Array], |
| 598 | indices: &[(usize, usize)], |
| 599 | ) -> Result<ArrayRef, ArrowError> { |
| 600 | let arrays: Vec<_> = values.iter().map(|x| x.to_data()).collect(); |
| 601 | let arrays: Vec<_> = arrays.iter().collect(); |
| 602 | let mut array_data = MutableArrayData::new(arrays, false, indices.len()); |
| 603 | |
| 604 | let mut cur_array = indices[0].0; |
| 605 | let mut start_row_idx = indices[0].1; |
| 606 | let mut end_row_idx = start_row_idx + 1; |
| 607 | |
| 608 | for (array, row) in indices.iter().skip(1).copied() { |
| 609 | if array == cur_array && row == end_row_idx { |
| 610 | // subsequent row in same batch |
| 611 | end_row_idx += 1; |
| 612 | continue; |
| 613 | } |
| 614 | |
| 615 | // emit current batch of rows for current buffer |
| 616 | array_data.extend(cur_array, start_row_idx, end_row_idx); |
| 617 | |
| 618 | // start new batch of rows |
| 619 | cur_array = array; |
| 620 | start_row_idx = row; |
| 621 | end_row_idx = start_row_idx + 1; |
| 622 | } |
| 623 | |
| 624 | // emit final batch of rows |
| 625 | array_data.extend(cur_array, start_row_idx, end_row_idx); |
| 626 | Ok(make_array(array_data.freeze())) |
| 627 | } |
| 628 | |
| 629 | /// Fallback implementation for interleaving dictionaries when it was determined |
| 630 | /// that the dictionary values should not be merged. This implementation concatenates |