Skip to content

Commit

Permalink
Merge branch 'master' into buffer-builder-scalar-buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel committed Dec 11, 2023
2 parents f213089 + 8aa55dd commit 27a0b6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions arrow-buffer/src/buffer/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion arrow-buffer/src/buffer/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::alloc::Deallocation;
use crate::buffer::Buffer;
use crate::native::ArrowNativeType;
use crate::{BufferBuilder, MutableBuffer};
use crate::{BufferBuilder, MutableBuffer, OffsetBuffer};
use std::fmt::Formatter;
use std::marker::PhantomData;
use std::ops::Deref;
Expand Down Expand Up @@ -145,6 +145,12 @@ impl<T: ArrowNativeType> From<Buffer> for ScalarBuffer<T> {
}
}

impl<T: ArrowNativeType> From<OffsetBuffer<T>> for ScalarBuffer<T> {
fn from(value: OffsetBuffer<T>) -> Self {
value.into_inner()
}
}

impl<T: ArrowNativeType> From<Vec<T>> for ScalarBuffer<T> {
fn from(value: Vec<T>) -> Self {
Self {
Expand Down

0 comments on commit 27a0b6f

Please sign in to comment.