| 88 | // --------------------------------------------------------------------------- |
| 89 | |
| 90 | fn build_range_row_selection( |
| 91 | total_rows: usize, |
| 92 | row_ranges: &[RowRange], |
| 93 | ) -> orc_rust::row_selection::RowSelection { |
| 94 | if total_rows == 0 { |
| 95 | return orc_rust::row_selection::RowSelection::default(); |
| 96 | } |
| 97 | |
| 98 | let file_end = total_rows as i64 - 1; |
| 99 | let mut local_ranges: Vec<(usize, usize)> = row_ranges |
| 100 | .iter() |
| 101 | .filter_map(|r| { |
| 102 | if r.to() < 0 || r.from() > file_end { |
| 103 | return None; |
| 104 | } |
| 105 | let local_start = r.from().max(0) as usize; |
| 106 | let local_end = (r.to().min(file_end) + 1) as usize; |
| 107 | Some((local_start, local_end)) |
| 108 | }) |
| 109 | .collect(); |
| 110 | local_ranges.sort_by_key(|&(s, _)| s); |
| 111 | |
| 112 | orc_rust::row_selection::RowSelection::from_consecutive_ranges( |
| 113 | local_ranges.into_iter().map(|(s, e)| s..e), |
| 114 | total_rows, |
| 115 | ) |
| 116 | } |
| 117 | |
| 118 | // --------------------------------------------------------------------------- |
| 119 | // OrcFileReader — adapts paimon FileRead to orc-rust AsyncChunkReader |