MCPcopy Create free account
hub / github.com/apache/datafusion / find_indices

Function find_indices

datafusion/common/src/utils/mod.rs:922–931  ·  view source on GitHub ↗

Find indices of each element in `targets` inside `items`. If one of the elements is absent in `items`, returns an error.

(
    items: &[T],
    targets: impl IntoIterator<Item = S>,
)

Source from the content-addressed store, hash-verified

920/// Find indices of each element in `targets` inside `items`. If one of the
921/// elements is absent in `items`, returns an error.
922pub fn find_indices<T: PartialEq, S: Borrow<T>>(
923 items: &[T],
924 targets: impl IntoIterator<Item = S>,
925) -> Result<Vec<usize>> {
926 targets
927 .into_iter()
928 .map(|target| items.iter().position(|e| target.borrow().eq(e)))
929 .collect::<Option<_>>()
930 .ok_or_else(|| _exec_datafusion_err!("Target not found"))
931}
932
933/// Transposes the given vector of vectors.
934pub fn transpose<T>(original: Vec<Vec<T>>) -> Vec<Vec<T>> {

Callers

nothing calls this directly

Calls 4

mapMethod · 0.45
into_iterMethod · 0.45
iterMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…