You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by jo...@apache.org on 2021/04/22 13:10:07 UTC
[arrow-rs] branch master updated: Buffer::from_slice_ref set
correct capacity (#18)
This is an automated email from the ASF dual-hosted git repository.
jorgecarleitao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new c3fe3ba Buffer::from_slice_ref set correct capacity (#18)
c3fe3ba is described below
commit c3fe3bab9905739fdda75301dab07a18c91731bd
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Thu Apr 22 14:09:59 2021 +0100
Buffer::from_slice_ref set correct capacity (#18)
Fixed ARROW-12504
---
arrow/src/buffer/immutable.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arrow/src/buffer/immutable.rs b/arrow/src/buffer/immutable.rs
index cd6a2a3..f4aeae9 100644
--- a/arrow/src/buffer/immutable.rs
+++ b/arrow/src/buffer/immutable.rs
@@ -55,8 +55,8 @@ impl Buffer {
/// Initializes a [Buffer] from a slice of items.
pub fn from_slice_ref<U: ArrowNativeType, T: AsRef<[U]>>(items: &T) -> Self {
let slice = items.as_ref();
- let len = slice.len();
- let mut buffer = MutableBuffer::with_capacity(len);
+ let capacity = slice.len() * std::mem::size_of::<U>();
+ let mut buffer = MutableBuffer::with_capacity(capacity);
buffer.extend_from_slice(slice);
buffer.into()
}