Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions arrow-select/src/coalesce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ mod tests {
use crate::concat::concat_batches;
use arrow_array::builder::StringViewBuilder;
use arrow_array::cast::AsArray;
use arrow_array::types::Int32Type;
use arrow_array::{
BinaryViewArray, Int32Array, Int64Array, RecordBatchOptions, StringArray, StringViewArray,
TimestampNanosecondArray, UInt32Array, UInt64Array,
Expand Down Expand Up @@ -1625,6 +1626,11 @@ mod tests {
// Now should have a completed batch (100 rows total)
assert!(coalescer.has_completed_batch());
let output_batch = coalescer.next_completed_batch().unwrap();
let size = output_batch
.column(0)
.as_primitive::<Int32Type>()
.get_buffer_memory_size();
assert_eq!(size, 400); // 100 rows * 4 bytes each
assert_eq!(output_batch.num_rows(), 100);

assert_eq!(coalescer.get_buffered_rows(), 0);
Expand Down
5 changes: 4 additions & 1 deletion arrow-select/src/coalesce/byte_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ impl<B: ByteViewType> InProgressByteViewArray<B> {
/// This is done on write (when we know it is necessary) rather than
/// eagerly to avoid allocations that are not used.
fn ensure_capacity(&mut self) {
self.views.reserve(self.batch_size);
if self.views.capacity() == 0 {
Comment thread
Dandandan marked this conversation as resolved.
self.views.reserve(self.batch_size);
}
debug_assert_eq!(self.views.capacity(), self.batch_size);
}

/// Finishes in progress buffer, if any
Expand Down
5 changes: 4 additions & 1 deletion arrow-select/src/coalesce/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ impl<T: ArrowPrimitiveType> InProgressPrimitiveArray<T> {
/// This is done on write (when we know it is necessary) rather than
/// eagerly to avoid allocations that are not used.
fn ensure_capacity(&mut self) {
self.current.reserve(self.batch_size);
if self.current.capacity() == 0 {
self.current.reserve(self.batch_size);
}
debug_assert_eq!(self.current.capacity(), self.batch_size);
}
}

Expand Down
Loading