MCPcopy Create free account
hub / github.com/apache/arrow-rs / interleave_fallback

Function interleave_fallback

arrow-select/src/interleave.rs:596–627  ·  view source on GitHub ↗

Fallback implementation of interleave using [`MutableArrayData`]

(
    values: &[&dyn Array],
    indices: &[(usize, usize)],
)

Source from the content-addressed store, hash-verified

594
595/// Fallback implementation of interleave using [`MutableArrayData`]
596fn 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

Callers 3

interleave_dictionariesFunction · 0.85
test_interleave_viewsFunction · 0.85

Calls 8

collectMethod · 0.80
freezeMethod · 0.80
make_arrayFunction · 0.50
iterMethod · 0.45
to_dataMethod · 0.45
lenMethod · 0.45
skipMethod · 0.45
extendMethod · 0.45

Tested by 2

test_interleave_viewsFunction · 0.68