Intersect two sorted lists of inclusive RowRanges using a merge-style scan.
(a: &[RowRange], b: &[RowRange])
| 365 | |
| 366 | /// Intersect two sorted lists of inclusive RowRanges using a merge-style scan. |
| 367 | fn intersect_sorted_ranges(a: &[RowRange], b: &[RowRange]) -> Vec<RowRange> { |
| 368 | let mut result = Vec::new(); |
| 369 | let (mut i, mut j) = (0, 0); |
| 370 | while i < a.len() && j < b.len() { |
| 371 | let from = a[i].from().max(b[j].from()); |
| 372 | let to = a[i].to().min(b[j].to()); |
| 373 | if from <= to { |
| 374 | result.push(RowRange::new(from, to)); |
| 375 | } |
| 376 | if a[i].to() < b[j].to() { |
| 377 | i += 1; |
| 378 | } else { |
| 379 | j += 1; |
| 380 | } |
| 381 | } |
| 382 | result |
| 383 | } |
| 384 | |
| 385 | /// Expand row_ranges into a flat sequence of selected row IDs for a file. |
| 386 | /// Intended for per-batch _ROW_ID attachment — callers should not pass |
no test coverage detected