This function searches for a tuple of given values (`target`) among a slice of the given rows (`item_columns`) using the bisection algorithm. The slice starts at the index `low` and ends at the index `high`. The boolean-valued function `compare_fn` specifies whether we bisect on the left (by returning `false`), or on the right (by returning `true`) when we compare the target value with the current
(
item_columns: &[ArrayRef],
target: &[ScalarValue],
compare_fn: F,
mut low: usize,
mut high: usize,
)
| 172 | /// or on the right (by returning `true`) when we compare the target value with |
| 173 | /// the current value as we iteratively bisect the input. |
| 174 | pub fn find_bisect_point<F>( |
| 175 | item_columns: &[ArrayRef], |
| 176 | target: &[ScalarValue], |
| 177 | compare_fn: F, |
| 178 | mut low: usize, |
| 179 | mut high: usize, |
| 180 | ) -> Result<usize> |
| 181 | where |
| 182 | F: Fn(&[ScalarValue], &[ScalarValue]) -> Result<bool>, |
| 183 | { |
| 184 | while low < high { |
| 185 | let mid = ((high - low) / 2) + low; |
| 186 | let val = get_row_at_idx(item_columns, mid)?; |
| 187 | if compare_fn(&val, target)? { |
| 188 | low = mid + 1; |
| 189 | } else { |
| 190 | high = mid; |
| 191 | } |
| 192 | } |
| 193 | Ok(low) |
| 194 | } |
| 195 | |
| 196 | /// This function searches for a tuple of given values (`target`) among the given |
| 197 | /// rows (`item_columns`) via a linear scan. It assumes that `item_columns` is sorted |
no test coverage detected
searching dependent graphs…