Skip to content

Commit fec3c02

Browse files
authored
fix: remove incorrect debug assertion in BatchCoalescer (#9508)
# Which issue does this PR close? - Closes #9506 # Rationale for this change `Vec::reserve(n)` does not guarantee exact capacity, Rust's `MIN_NON_ZERO_CAP` optimization means `reserve(2)` gives capacity = 4 for most numeric types, causing `debug_assert_eq!(capacity, batch_size)` to panic in debug mode when `batch_size < 4`. # What changes are included in this PR? Replace `reserve` with `reserve_exact` in `ensure_capacity` in both `InProgressPrimitiveArray` and `InProgressByteViewArray`. `reserve_exact` skips the amortized growth optimization and allocates exactly the requested capacity, making the assertion correct. # Are these changes tested? No. This only fixes an incorrect debug assertion. # Are there any user-facing changes? No
1 parent 097c203 commit fec3c02

File tree

2 files changed

+0
-2
lines changed

2 files changed

+0
-2
lines changed

arrow-select/src/coalesce/byte_view.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ impl<B: ByteViewType> InProgressByteViewArray<B> {
101101
if self.views.capacity() == 0 {
102102
self.views.reserve(self.batch_size);
103103
}
104-
debug_assert_eq!(self.views.capacity(), self.batch_size);
105104
}
106105

107106
/// Finishes in progress buffer, if any

arrow-select/src/coalesce/primitive.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ impl<T: ArrowPrimitiveType> InProgressPrimitiveArray<T> {
5858
if self.current.capacity() == 0 {
5959
self.current.reserve(self.batch_size);
6060
}
61-
debug_assert_eq!(self.current.capacity(), self.batch_size);
6261
}
6362
}
6463

0 commit comments

Comments
 (0)