Struct arrow::array::MutableArrayData
source · [−]pub struct MutableArrayData<'a> { /* private fields */ }
Expand description
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 arrow::{array::{Int32Array, Array, MutableArrayData}};
let array = Int32Array::from(vec![1, 2, 3, 4, 5]);
let array = array.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];
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(mutable.freeze());
assert_eq!(Int32Array::from(vec![2, 3, 1, 2, 3]), new_array);
Implementations
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 with_capacities(
arrays: Vec<&'a ArrayData>,
use_nulls: bool,
capacities: Capacities
) -> Self
pub fn with_capacities(
arrays: Vec<&'a ArrayData>,
use_nulls: bool,
capacities: Capacities
) -> Self
Similar to [MutableArray::new], but lets users define the preallocated capacities of the array. See also [MutableArray::new] for more information on the arguments.
Panic
This function panics if the given capacities
don’t match the data type of arrays
. Or when
a Capacities variant is not yet supported.
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()
.
Extends this MutableArrayData with null elements, disregarding the bound arrays
Returns the current null count
Creates a ArrayData from the pushed regions up to this point, consuming self
.
Creates a ArrayDataBuilder from the pushed regions up to this point, consuming self
.
This is useful for extending the default behavior of MutableArrayData.