Skip to content

Commit

Permalink
use take instead of drain
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel committed Feb 23, 2024
1 parent e67c99b commit cb92fbb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/connector/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,13 @@ async fn ensure_largest_at_rate_limit(stream: BoxSourceStream, rate_limit: u32)
#[for_await]
for batch in stream {
let mut batch = batch?;
while batch.len() > rate_limit as usize {
yield batch.drain(..rate_limit as usize).collect();
let mut start = 0;
let end = batch.len();
while start < end {
let next = std::cmp::min(start + rate_limit as usize, end);
yield std::mem::take(&mut batch[start..next].as_mut()).to_vec();
start = next;
}
yield batch;
}
}

Expand Down

0 comments on commit cb92fbb

Please sign in to comment.