[−][src]Struct arrow::array::MutableArrayData
Struct to efficiently and interactively create an ArrayData from an existing ArrayData by
copying chunks.
The main use case of this struct is to perform unary operations to arrays of arbitrary types, such as filter
and take
.
Example:
use std::sync::Arc; use arrow::{array::{Int32Array, Array, MutableArrayData}}; let array = Int32Array::from(vec![1, 2, 3, 4, 5]).data(); // Create a new `MutableArrayData` from an array and with a capacity of 4. // Capacity here is equivalent to `Vec::with_capacity` let arrays = vec![array.as_ref()]; let mut mutable = MutableArrayData::new(arrays, false, 4); mutable.extend(0, 1, 3); // extend from the slice [1..3], [2,3] mutable.extend(0, 0, 3); // extend from the slice [0..3], [1,2,3] // `.freeze()` to convert `MutableArrayData` into a `ArrayData`. let new_array = Int32Array::from(Arc::new(mutable.freeze())); assert_eq!(Int32Array::from(vec![2, 3, 1, 2, 3]), new_array);
Implementations
impl<'a> MutableArrayData<'a>
[src]
pub fn new(
arrays: Vec<&'a ArrayData>,
mut use_nulls: bool,
capacity: usize
) -> Self
[src]
arrays: Vec<&'a ArrayData>,
mut use_nulls: bool,
capacity: usize
) -> Self
returns a new MutableArrayData with capacity to capacity
slots and specialized to create an
ArrayData from multiple arrays
.
use_nulls
is a flag used to optimize insertions. It should be false
if the only source of nulls
are the arrays themselves and true
if the user plans to call MutableArrayData::extend_nulls.
In other words, if use_nulls
is false
, calling MutableArrayData::extend_nulls should not be used.
pub fn extend(&mut self, index: usize, start: usize, end: usize)
[src]
Extends this MutableArrayData with elements from the bounded ArrayData at start
and for a size of len
.
Panic
This function panics if the range is out of bounds, i.e. if start + len >= array.len()
.
pub fn extend_nulls(&mut self, len: usize)
[src]
Extends this MutableArrayData with null elements, disregarding the bound arrays
pub fn freeze(self) -> ArrayData
[src]
Creates a ArrayData from the pushed regions up to this point, consuming self
.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for MutableArrayData<'a>
[src]
impl<'a> !Send for MutableArrayData<'a>
[src]
impl<'a> !Sync for MutableArrayData<'a>
[src]
impl<'a> Unpin for MutableArrayData<'a>
[src]
impl<'a> !UnwindSafe for MutableArrayData<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,