This function searches for a tuple of given values (`target`) among the given rows (`item_columns`) using the bisection algorithm. It assumes that `item_columns` is sorted according to `sort_options` and returns the insertion index of `target`. Template argument `SIDE` being `true`/`false` means left/right insertion.
(
item_columns: &[ArrayRef],
target: &[ScalarValue],
sort_options: &[SortOptions],
)
| 149 | /// is sorted according to `sort_options` and returns the insertion index of `target`. |
| 150 | /// Template argument `SIDE` being `true`/`false` means left/right insertion. |
| 151 | pub fn bisect<const SIDE: bool>( |
| 152 | item_columns: &[ArrayRef], |
| 153 | target: &[ScalarValue], |
| 154 | sort_options: &[SortOptions], |
| 155 | ) -> Result<usize> { |
| 156 | let low: usize = 0; |
| 157 | let high: usize = item_columns |
| 158 | .first() |
| 159 | .ok_or_else(|| _internal_datafusion_err!("Column array shouldn't be empty"))? |
| 160 | .len(); |
| 161 | let compare_fn = |current: &[ScalarValue], target: &[ScalarValue]| { |
| 162 | let cmp = compare_rows(current, target, sort_options)?; |
| 163 | Ok(if SIDE { cmp.is_lt() } else { cmp.is_le() }) |
| 164 | }; |
| 165 | find_bisect_point(item_columns, target, compare_fn, low, high) |
| 166 | } |
| 167 | |
| 168 | /// This function searches for a tuple of given values (`target`) among a slice of |
| 169 | /// the given rows (`item_columns`) using the bisection algorithm. The slice starts |
nothing calls this directly
no test coverage detected
searching dependent graphs…