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

Function search_in_slice

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

This function searches for a tuple of given values (`target`) among a slice of the given rows (`item_columns`) via a linear scan. The slice starts at the index `low` and ends at the index `high`. The boolean-valued function `compare_fn` specifies the stopping criterion.

(
    item_columns: &[ArrayRef],
    target: &[ScalarValue],
    compare_fn: F,
    mut low: usize,
    high: usize,
)

Source from the content-addressed store, hash-verified

219/// `low` and ends at the index `high`. The boolean-valued function `compare_fn`
220/// specifies the stopping criterion.
221pub fn search_in_slice<F>(
222 item_columns: &[ArrayRef],
223 target: &[ScalarValue],
224 compare_fn: F,
225 mut low: usize,
226 high: usize,
227) -> Result<usize>
228where
229 F: Fn(&[ScalarValue], &[ScalarValue]) -> Result<bool>,
230{
231 while low < high {
232 let val = get_row_at_idx(item_columns, low)?;
233 if !compare_fn(&val, target)? {
234 break;
235 }
236 low += 1;
237 }
238 Ok(low)
239}
240
241/// Given a list of 0 or more already sorted columns, finds the
242/// partition ranges that would partition equally across columns.

Callers 2

linear_searchFunction · 0.85

Calls 1

get_row_at_idxFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…