This is an automated email from the ASF dual-hosted git repository.

tustvold 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 8aa55ddc1c impl `From<BufferBuilder<T>>` for `Buffer` (#5202)
8aa55ddc1c is described below

commit 8aa55ddc1cce8893d0ea09029b149f0239060646
Author: Matthijs Brobbel <[email protected]>
AuthorDate: Mon Dec 11 18:21:47 2023 +0100

    impl `From<BufferBuilder<T>>` for `Buffer` (#5202)
---
 arrow-buffer/src/buffer/immutable.rs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arrow-buffer/src/buffer/immutable.rs 
b/arrow-buffer/src/buffer/immutable.rs
index 8869ab3a22..9db8732f36 100644
--- a/arrow-buffer/src/buffer/immutable.rs
+++ b/arrow-buffer/src/buffer/immutable.rs
@@ -23,6 +23,7 @@ use std::sync::Arc;
 
 use crate::alloc::{Allocation, Deallocation, ALIGNMENT};
 use crate::util::bit_chunk_iterator::{BitChunks, UnalignedBitChunk};
+use crate::BufferBuilder;
 use crate::{bytes::Bytes, native::ArrowNativeType};
 
 use super::ops::bitwise_unary_op_helper;
@@ -371,6 +372,12 @@ impl From<MutableBuffer> for Buffer {
     }
 }
 
+impl<T: ArrowNativeType> From<BufferBuilder<T>> for Buffer {
+    fn from(mut value: BufferBuilder<T>) -> Self {
+        value.finish()
+    }
+}
+
 impl Buffer {
     /// Creates a [`Buffer`] from an [`Iterator`] with a trusted (upper) 
length.
     /// Prefer this to `collect` whenever possible, as it is ~60% faster.

Reply via email to