pub fn slices(
pairs: &[(&[&dyn Array], &SortOptions)]
) -> Result<Vec<MergeSlice>>
Available on crate feature
compute_merge_sort
only.Expand description
Returns a vector of slices from different sorted arrays that can be used to create sorted arrays.
pairs
is an array representing multiple sorted array sets. The expected format is
pairs: [([a00, a01], o1), ([a10, a11], o2), …]
where aj0.len() == aj0.len()
aj1.len() == aj1.len()
…
In other words, pairs.i.0[j]
must be an array coming from a batch of equal len arrays.
Example
use arrow2::array::Int32Array;
use arrow2::compute::merge_sort::{slices, SortOptions};
let a = Int32Array::from_slice(&[2, 4, 6]);
let b = Int32Array::from_slice(&[0, 1, 3]);
let slices = slices(&[(&[&a, &b], &SortOptions::default())])?;
assert_eq!(slices, vec![(1, 0, 2), (0, 0, 1), (1, 2, 1), (0, 1, 2)]);
Error
This function errors if the arrays a0i
are not pairwise sortable. This happens when either
they have not the same crate::datatypes::DataType
or when their crate::datatypes::DataType
does not correspond to a sortable type.
Panic
This function panics if:
pairs
has no elements- the length condition above is not fulfilled