Expand row_ranges into a flat sequence of selected row IDs for a file. Intended for per-batch _ROW_ID attachment — callers should not pass whole-file ranges with millions of rows, as this allocates a Vec proportional to the selected range size.
(
first_row_id: i64,
row_count: i64,
row_ranges: &[RowRange],
)
| 387 | /// whole-file ranges with millions of rows, as this allocates a Vec<i64> |
| 388 | /// proportional to the selected range size. |
| 389 | pub(super) fn expand_selected_row_ids( |
| 390 | first_row_id: i64, |
| 391 | row_count: i64, |
| 392 | row_ranges: &[RowRange], |
| 393 | ) -> Vec<i64> { |
| 394 | if row_count == 0 { |
| 395 | return Vec::new(); |
| 396 | } |
| 397 | let file_end = first_row_id + row_count - 1; |
| 398 | let mut ids = Vec::new(); |
| 399 | for r in row_ranges { |
| 400 | let from = r.from().max(first_row_id); |
| 401 | let to = r.to().min(file_end); |
| 402 | for id in from..=to { |
| 403 | ids.push(id); |
| 404 | } |
| 405 | } |
| 406 | ids |
| 407 | } |
| 408 | |
| 409 | pub(super) fn attach_row_id( |
| 410 | batch: RecordBatch, |
no test coverage detected