Skip to content

Commit

Permalink
feat(migrate-from-gcs): batch decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
alextes committed Oct 16, 2023
1 parent b19d50d commit d6f919e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/bin/migrate-from-gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ async fn main() -> anyhow::Result<()> {
let mut csv_reader = csv::Reader::from_reader(decoder);
let mut iter = csv_reader.byte_records();

let mut batch = Vec::new();

while let Some(record) = iter.next().transpose().unwrap() {
let execution_payload = {
unsafe {
Expand All @@ -213,7 +215,15 @@ async fn main() -> anyhow::Result<()> {
}
};

futures::executor::block_on(decoded_tx.send(execution_payload)).unwrap();
batch.push(execution_payload);

if batch.len() == 32 {
for execution_payload in batch.drain(..) {
futures::executor::block_on(decoded_tx.feed(execution_payload)).unwrap();
}
futures::executor::block_on(decoded_tx.flush()).unwrap();
batch.clear();
}
}
});

Expand Down

0 comments on commit d6f919e

Please sign in to comment.