Skip to content

Commit

Permalink
ref(rust): Do not do extra work when merging if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
phacops committed Jan 3, 2024
1 parent b211283 commit c217fe5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rust_snuba/rust_arroyo/src/processing/strategies/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ impl<T, TResult> BatchState<T, TResult> {

let tmp = self.value.take().unwrap();
let payload = message.into_payload();
self.message_count += (self.compute_batch_size)(&payload);
self.value = Some((self.accumulator)(tmp, payload));
let batch_size = (self.compute_batch_size)(&payload);

if batch_size > 0 {
self.message_count += batch_size;
self.value = Some((self.accumulator)(tmp, payload));
}
}
}

Expand Down

0 comments on commit c217fe5

Please sign in to comment.