MCPcopy Create free account
hub / github.com/apache/paimon-rust / intersect_range_lists

Function intersect_range_lists

crates/paimon/src/table/row_id_predicate.rs:149–165  ·  view source on GitHub ↗

Intersect two sorted range lists.

(a: &[RowRange], b: &[RowRange])

Source from the content-addressed store, hash-verified

147
148/// Intersect two sorted range lists.
149fn intersect_range_lists(a: &[RowRange], b: &[RowRange]) -> Vec<RowRange> {
150 let mut result = Vec::new();
151 let (mut i, mut j) = (0, 0);
152 while i < a.len() && j < b.len() {
153 let from = a[i].from().max(b[j].from());
154 let to = a[i].to().min(b[j].to());
155 if from <= to {
156 result.push(RowRange::new(from, to));
157 }
158 if a[i].to() < b[j].to() {
159 i += 1;
160 } else {
161 j += 1;
162 }
163 }
164 result
165}
166
167#[cfg(test)]
168mod tests {

Callers 1

extract_row_id_rangesFunction · 0.85

Calls 3

toMethod · 0.80
lenMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected