From e75937d814ff6758ee8ab7b62ac1cc2f0a4a3197 Mon Sep 17 00:00:00 2001 From: Chris Macklin Date: Tue, 27 Aug 2024 11:35:09 -0700 Subject: [PATCH] Fix comparison to allow item buffers to be filled completely. (#54) The comparison to buffer capacity should be `>`, not `>=`. The current comparison prevents the item buffers from ever being totally full, which implies that the final shard written from each buffer is smaller than the others by `sender_buffer_size` --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1bd1b53f..8ca63c5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -352,7 +352,7 @@ impl> BufferStateMachine { let (mut new_state, outcome) = match current_state { FillAndWait(mut f, w) => { f.append(items); - if f.len() + self.sender_buffer_size >= f.capacity() { + if f.len() + self.sender_buffer_size > f.capacity() { (FillAndBusy(w), Process(f)) } else { (FillAndWait(f, w), Done) @@ -360,7 +360,7 @@ impl> BufferStateMachine { } FillAndBusy(mut f) => { f.append(items); - if f.len() + self.sender_buffer_size >= f.capacity() { + if f.len() + self.sender_buffer_size > f.capacity() { (BothBusy, Process(f)) } else { (FillAndBusy(f), Done)