Skip to content

Commit fa5eeda

Browse files
authored
feat: optimize repeatedScan for limit == 0 (#6015)
Problem Description: In the original implementation, even after the limit had decreased to 0 in the previous splits, the iterator would still continue traversing thousands of subsequent intervals. Although each interval only performed the `is_some_and` check once, it still incurred unnecessary traversal overhead. Solution: This optimization immediately executes `break` when `limit == 0` is detected, ensuring that subsequent intervals are no longer traversed. Signed-off-by: cancaicai <2356672992@qq.com>
1 parent a30298b commit fa5eeda

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

vortex-scan/src/repeated_scan.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,21 @@ impl<A: 'static + Send> RepeatedScan<A> {
161161
};
162162

163163
let mut limit = self.limit;
164-
ranges
165-
.filter_map(|range| {
166-
if range.start >= range.end || limit.is_some_and(|l| l == 0) {
167-
None
168-
} else {
169-
Some(split_exec(ctx.clone(), range, limit.as_mut()))
170-
}
171-
})
172-
.try_collect()
164+
let mut tasks = Vec::new();
165+
166+
for range in ranges {
167+
if range.start >= range.end {
168+
continue;
169+
}
170+
171+
if limit.is_some_and(|l| l == 0) {
172+
break;
173+
}
174+
175+
tasks.push(split_exec(ctx.clone(), range, limit.as_mut())?);
176+
}
177+
178+
Ok(tasks)
173179
}
174180

175181
pub fn execute_stream(

0 commit comments

Comments
 (0)