Struct arrow2::array::MutablePrimitiveArray
source · pub struct MutablePrimitiveArray<T: NativeType> { /* private fields */ }
Expand description
The Arrow’s equivalent to Vec<Option<T>>
where T
is byte-size (e.g. i32
).
Converting a MutablePrimitiveArray
into a PrimitiveArray
is O(1)
.
Implementations§
source§impl<'a, T: NativeType> MutablePrimitiveArray<T>
impl<'a, T: NativeType> MutablePrimitiveArray<T>
sourcepub fn iter(&'a self) -> ZipValidity<&'a T, Iter<'a, T>, BitmapIter<'a>> ⓘ
pub fn iter(&'a self) -> ZipValidity<&'a T, Iter<'a, T>, BitmapIter<'a>> ⓘ
Returns an iterator over Option<T>
sourcepub fn values_iter(&'a self) -> Iter<'a, T>
pub fn values_iter(&'a self) -> Iter<'a, T>
Returns an iterator of T
source§impl<T: NativeType> MutablePrimitiveArray<T>
impl<T: NativeType> MutablePrimitiveArray<T>
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty MutablePrimitiveArray
.
Examples found in repository?
More examples
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
fn from(values: M) -> Self {
Self {
data_type: DataType::Dictionary(
K::KEY_TYPE,
Box::new(values.data_type().clone()),
false,
),
keys: MutablePrimitiveArray::<K>::new(),
map: HashedMap::default(),
values,
}
}
}
impl<K: DictionaryKey, M: MutableArray + Default> MutableDictionaryArray<K, M> {
/// Creates an empty [`MutableDictionaryArray`].
pub fn new() -> Self {
let values = M::default();
Self {
data_type: DataType::Dictionary(
K::KEY_TYPE,
Box::new(values.data_type().clone()),
false,
),
keys: MutablePrimitiveArray::<K>::new(),
map: HashedMap::default(),
values,
}
}
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
fn allocate_array(f: &Field) -> Box<dyn MutableArray> {
match f.data_type() {
DataType::Int8 => Box::new(MutablePrimitiveArray::<i8>::new()),
DataType::Int16 => Box::new(MutablePrimitiveArray::<i16>::new()),
DataType::Int32 => Box::new(MutablePrimitiveArray::<i32>::new()),
DataType::Int64 => Box::new(MutablePrimitiveArray::<i64>::new()),
DataType::UInt8 => Box::new(MutablePrimitiveArray::<u8>::new()),
DataType::UInt16 => Box::new(MutablePrimitiveArray::<u16>::new()),
DataType::UInt32 => Box::new(MutablePrimitiveArray::<u32>::new()),
DataType::UInt64 => Box::new(MutablePrimitiveArray::<u64>::new()),
DataType::Float16 => Box::new(MutablePrimitiveArray::<f16>::new()),
DataType::Float32 => Box::new(MutablePrimitiveArray::<f32>::new()),
DataType::Float64 => Box::new(MutablePrimitiveArray::<f64>::new()),
DataType::FixedSizeList(inner, size) => Box::new(MutableFixedSizeListArray::<_>::new_from(
allocate_array(inner),
f.data_type().clone(),
*size,
)),
DataType::List(inner) => match inner.data_type() {
DataType::List(_) => Box::new(MutableListArray::<i32, _>::new_from(
allocate_array(inner),
inner.data_type().clone(),
0,
)),
_ => allocate_array(inner),
},
_ => todo!(),
}
}
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new MutablePrimitiveArray
with a capacity.
Examples found in repository?
More examples
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
fn fill_array_from<B, T, A>(
f: fn(&mut MutablePrimitiveArray<T>, &[B]),
data_type: DataType,
rows: &[B],
) -> Box<dyn Array>
where
T: NativeType,
A: From<MutablePrimitiveArray<T>> + Array,
{
let mut array = MutablePrimitiveArray::<T>::with_capacity(rows.len()).to(data_type);
f(&mut array, rows);
Box::new(A::from(array))
}
/// A trait describing an array with a backing store that can be preallocated to
/// a given size.
pub(crate) trait Container {
/// Create this array with a given capacity.
fn with_capacity(capacity: usize) -> Self
where
Self: Sized;
}
impl<O: Offset> Container for MutableBinaryArray<O> {
fn with_capacity(capacity: usize) -> Self {
MutableBinaryArray::with_capacity(capacity)
}
}
impl Container for MutableBooleanArray {
fn with_capacity(capacity: usize) -> Self {
MutableBooleanArray::with_capacity(capacity)
}
}
impl Container for MutableFixedSizeBinaryArray {
fn with_capacity(capacity: usize) -> Self {
MutableFixedSizeBinaryArray::with_capacity(capacity, 0)
}
}
impl<O: Offset, M: MutableArray + Default + 'static> Container for MutableListArray<O, M> {
fn with_capacity(capacity: usize) -> Self {
MutableListArray::with_capacity(capacity)
}
}
impl<T: NativeType> Container for MutablePrimitiveArray<T> {
fn with_capacity(capacity: usize) -> Self {
MutablePrimitiveArray::with_capacity(capacity)
}
sourcepub fn try_new(
data_type: DataType,
values: Vec<T>,
validity: Option<MutableBitmap>
) -> Result<Self, Error>
pub fn try_new(
data_type: DataType,
values: Vec<T>,
validity: Option<MutableBitmap>
) -> Result<Self, Error>
The canonical method to create a MutablePrimitiveArray
out of its internal components.
Implementation
This function is O(1)
.
Errors
This function errors iff:
- The validity is not
None
and its length is different fromvalues
’s length - The
data_type
’scrate::datatypes::PhysicalType
is not equal to [crate::datatypes::PhysicalType::Primitive(T::PRIMITIVE)
]
Examples found in repository?
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
pub fn to(self, data_type: DataType) -> Self {
Self::try_new(data_type, self.values, self.validity).unwrap()
}
/// Converts itself into an [`Array`].
pub fn into_arc(self) -> Arc<dyn Array> {
let a: PrimitiveArray<T> = self.into();
Arc::new(a)
}
/// Shrinks the capacity of the [`MutablePrimitiveArray`] to fit its current length.
pub fn shrink_to_fit(&mut self) {
self.values.shrink_to_fit();
if let Some(validity) = &mut self.validity {
validity.shrink_to_fit()
}
}
/// Returns the capacity of this [`MutablePrimitiveArray`].
pub fn capacity(&self) -> usize {
self.values.capacity()
}
}
/// Accessors
impl<T: NativeType> MutablePrimitiveArray<T> {
/// Returns its values.
pub fn values(&self) -> &Vec<T> {
&self.values
}
/// Returns a mutable slice of values.
pub fn values_mut_slice(&mut self) -> &mut [T] {
self.values.as_mut_slice()
}
}
/// Setters
impl<T: NativeType> MutablePrimitiveArray<T> {
/// Sets position `index` to `value`.
/// Note that if it is the first time a null appears in this array,
/// this initializes the validity bitmap (`O(N)`).
/// # Panic
/// Panics iff index is larger than `self.len()`.
pub fn set(&mut self, index: usize, value: Option<T>) {
assert!(index < self.len());
// Safety:
// we just checked bounds
unsafe { self.set_unchecked(index, value) }
}
/// Sets position `index` to `value`.
/// Note that if it is the first time a null appears in this array,
/// this initializes the validity bitmap (`O(N)`).
/// # Safety
/// Caller must ensure `index < self.len()`
pub unsafe fn set_unchecked(&mut self, index: usize, value: Option<T>) {
*self.values.get_unchecked_mut(index) = value.unwrap_or_default();
if value.is_none() && self.validity.is_none() {
// When the validity is None, all elements so far are valid. When one of the elements is set fo null,
// the validity must be initialized.
let mut validity = MutableBitmap::new();
validity.extend_constant(self.len(), true);
self.validity = Some(validity);
}
if let Some(x) = self.validity.as_mut() {
x.set_unchecked(index, value.is_some())
}
}
/// Sets the validity.
/// # Panic
/// Panics iff the validity's len is not equal to the existing values' length.
pub fn set_validity(&mut self, validity: Option<MutableBitmap>) {
if let Some(validity) = &validity {
assert_eq!(self.values.len(), validity.len())
}
self.validity = validity;
}
/// Sets values.
/// # Panic
/// Panics iff the values' length is not equal to the existing validity's len.
pub fn set_values(&mut self, values: Vec<T>) {
assert_eq!(values.len(), self.values.len());
self.values = values;
}
}
impl<T: NativeType> Extend<Option<T>> for MutablePrimitiveArray<T> {
fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I) {
let iter = iter.into_iter();
self.reserve(iter.size_hint().0);
iter.for_each(|x| self.push(x))
}
}
impl<T: NativeType> TryExtend<Option<T>> for MutablePrimitiveArray<T> {
/// This is infalible and is implemented for consistency with all other types
fn try_extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I) -> Result<(), Error> {
self.extend(iter);
Ok(())
}
}
impl<T: NativeType> TryPush<Option<T>> for MutablePrimitiveArray<T> {
/// This is infalible and is implemented for consistency with all other types
fn try_push(&mut self, item: Option<T>) -> Result<(), Error> {
self.push(item);
Ok(())
}
}
impl<T: NativeType> MutableArray for MutablePrimitiveArray<T> {
fn len(&self) -> usize {
self.values.len()
}
fn validity(&self) -> Option<&MutableBitmap> {
self.validity.as_ref()
}
fn as_box(&mut self) -> Box<dyn Array> {
PrimitiveArray::new(
self.data_type.clone(),
std::mem::take(&mut self.values).into(),
std::mem::take(&mut self.validity).map(|x| x.into()),
)
.boxed()
}
fn as_arc(&mut self) -> Arc<dyn Array> {
PrimitiveArray::new(
self.data_type.clone(),
std::mem::take(&mut self.values).into(),
std::mem::take(&mut self.validity).map(|x| x.into()),
)
.arced()
}
fn data_type(&self) -> &DataType {
&self.data_type
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_mut_any(&mut self) -> &mut dyn std::any::Any {
self
}
fn push_null(&mut self) {
self.push(None)
}
fn reserve(&mut self, additional: usize) {
self.reserve(additional)
}
fn shrink_to_fit(&mut self) {
self.shrink_to_fit()
}
}
impl<T: NativeType> MutablePrimitiveArray<T> {
/// Creates a [`MutablePrimitiveArray`] from a slice of values.
pub fn from_slice<P: AsRef<[T]>>(slice: P) -> Self {
Self::from_trusted_len_values_iter(slice.as_ref().iter().copied())
}
/// Creates a [`MutablePrimitiveArray`] from an iterator of trusted length.
/// # Safety
/// The iterator must be [`TrustedLen`](https://doc.rust-lang.org/std/iter/trait.TrustedLen.html).
/// I.e. `size_hint().1` correctly reports its length.
#[inline]
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self
where
P: std::borrow::Borrow<T>,
I: Iterator<Item = Option<P>>,
{
let (validity, values) = trusted_len_unzip(iterator);
Self {
data_type: T::PRIMITIVE.into(),
values,
validity,
}
}
/// Creates a [`MutablePrimitiveArray`] from a [`TrustedLen`].
#[inline]
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Self
where
P: std::borrow::Borrow<T>,
I: TrustedLen<Item = Option<P>>,
{
unsafe { Self::from_trusted_len_iter_unchecked(iterator) }
}
/// Creates a [`MutablePrimitiveArray`] from an fallible iterator of trusted length.
/// # Safety
/// The iterator must be [`TrustedLen`](https://doc.rust-lang.org/std/iter/trait.TrustedLen.html).
/// I.e. that `size_hint().1` correctly reports its length.
#[inline]
pub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iter: I,
) -> std::result::Result<Self, E>
where
P: std::borrow::Borrow<T>,
I: IntoIterator<Item = std::result::Result<Option<P>, E>>,
{
let iterator = iter.into_iter();
let (validity, values) = try_trusted_len_unzip(iterator)?;
Ok(Self {
data_type: T::PRIMITIVE.into(),
values,
validity,
})
}
/// Creates a [`MutablePrimitiveArray`] from an fallible iterator of trusted length.
#[inline]
pub fn try_from_trusted_len_iter<E, I, P>(iterator: I) -> std::result::Result<Self, E>
where
P: std::borrow::Borrow<T>,
I: TrustedLen<Item = std::result::Result<Option<P>, E>>,
{
unsafe { Self::try_from_trusted_len_iter_unchecked(iterator) }
}
/// Creates a new [`MutablePrimitiveArray`] out an iterator over values
pub fn from_trusted_len_values_iter<I: TrustedLen<Item = T>>(iter: I) -> Self {
Self {
data_type: T::PRIMITIVE.into(),
values: iter.collect(),
validity: None,
}
}
/// Creates a (non-null) [`MutablePrimitiveArray`] from a vector of values.
/// This does not have memcopy and is the fastest way to create a [`PrimitiveArray`].
pub fn from_vec(values: Vec<T>) -> Self {
Self::try_new(T::PRIMITIVE.into(), values, None).unwrap()
}
More examples
274 275 276 277 278 279 280 281 282 283 284 285
pub(super) fn finish<T: NativeType>(
data_type: &DataType,
values: Vec<T>,
validity: MutableBitmap,
) -> MutablePrimitiveArray<T> {
let validity = if validity.is_empty() {
None
} else {
Some(validity)
};
MutablePrimitiveArray::try_new(data_type.clone(), values, validity).unwrap()
}
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
pub fn into_mut(mut self) -> Either<Self, MutablePrimitiveArray<T>> {
use Either::*;
if let Some(bitmap) = self.validity {
match bitmap.into_mut() {
Left(bitmap) => Left(PrimitiveArray::new(
self.data_type,
self.values,
Some(bitmap),
)),
Right(mutable_bitmap) => match self.values.get_mut().map(std::mem::take) {
Some(values) => Right(
MutablePrimitiveArray::try_new(
self.data_type,
values,
Some(mutable_bitmap),
)
.unwrap(),
),
None => Left(PrimitiveArray::new(
self.data_type,
self.values,
Some(mutable_bitmap.into()),
)),
},
}
} else {
match self.values.get_mut().map(std::mem::take) {
Some(values) => {
Right(MutablePrimitiveArray::try_new(self.data_type, values, None).unwrap())
}
None => Left(PrimitiveArray::new(self.data_type, self.values, None)),
}
}
}
sourcepub fn into_inner(self) -> (DataType, Vec<T>, Option<MutableBitmap>)
pub fn into_inner(self) -> (DataType, Vec<T>, Option<MutableBitmap>)
Extract the low-end APIs from the MutablePrimitiveArray
.
sourcepub fn apply_values<F: Fn(&mut [T])>(&mut self, f: F)
pub fn apply_values<F: Fn(&mut [T])>(&mut self, f: F)
Applies a function f
to the values of this array, cloning the values
iff they are being shared with others
This is an API to use clone-on-write
Implementation
This function is O(f)
if the data is not being shared, and O(N) + O(f)
if it is being shared (since it results in a O(N)
memcopy).
Panics
This function panics iff f
panics
source§impl<T: NativeType> MutablePrimitiveArray<T>
impl<T: NativeType> MutablePrimitiveArray<T>
sourcepub fn with_capacity_from(capacity: usize, data_type: DataType) -> Self
pub fn with_capacity_from(capacity: usize, data_type: DataType) -> Self
Creates a new MutablePrimitiveArray
from a capacity and DataType
.
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves additional
entries.
Examples found in repository?
More examples
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I) {
let iter = iter.into_iter();
self.reserve(iter.size_hint().0);
iter.for_each(|x| self.push(x))
}
}
impl<T: NativeType> TryExtend<Option<T>> for MutablePrimitiveArray<T> {
/// This is infalible and is implemented for consistency with all other types
fn try_extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I) -> Result<(), Error> {
self.extend(iter);
Ok(())
}
}
impl<T: NativeType> TryPush<Option<T>> for MutablePrimitiveArray<T> {
/// This is infalible and is implemented for consistency with all other types
fn try_push(&mut self, item: Option<T>) -> Result<(), Error> {
self.push(item);
Ok(())
}
}
impl<T: NativeType> MutableArray for MutablePrimitiveArray<T> {
fn len(&self) -> usize {
self.values.len()
}
fn validity(&self) -> Option<&MutableBitmap> {
self.validity.as_ref()
}
fn as_box(&mut self) -> Box<dyn Array> {
PrimitiveArray::new(
self.data_type.clone(),
std::mem::take(&mut self.values).into(),
std::mem::take(&mut self.validity).map(|x| x.into()),
)
.boxed()
}
fn as_arc(&mut self) -> Arc<dyn Array> {
PrimitiveArray::new(
self.data_type.clone(),
std::mem::take(&mut self.values).into(),
std::mem::take(&mut self.validity).map(|x| x.into()),
)
.arced()
}
fn data_type(&self) -> &DataType {
&self.data_type
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_mut_any(&mut self) -> &mut dyn std::any::Any {
self
}
fn push_null(&mut self) {
self.push(None)
}
fn reserve(&mut self, additional: usize) {
self.reserve(additional)
}
sourcepub fn push(&mut self, value: Option<T>)
pub fn push(&mut self, value: Option<T>)
Adds a new value to the array.
Examples found in repository?
More examples
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I) {
let iter = iter.into_iter();
self.reserve(iter.size_hint().0);
iter.for_each(|x| self.push(x))
}
}
impl<T: NativeType> TryExtend<Option<T>> for MutablePrimitiveArray<T> {
/// This is infalible and is implemented for consistency with all other types
fn try_extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I) -> Result<(), Error> {
self.extend(iter);
Ok(())
}
}
impl<T: NativeType> TryPush<Option<T>> for MutablePrimitiveArray<T> {
/// This is infalible and is implemented for consistency with all other types
fn try_push(&mut self, item: Option<T>) -> Result<(), Error> {
self.push(item);
Ok(())
}
}
impl<T: NativeType> MutableArray for MutablePrimitiveArray<T> {
fn len(&self) -> usize {
self.values.len()
}
fn validity(&self) -> Option<&MutableBitmap> {
self.validity.as_ref()
}
fn as_box(&mut self) -> Box<dyn Array> {
PrimitiveArray::new(
self.data_type.clone(),
std::mem::take(&mut self.values).into(),
std::mem::take(&mut self.validity).map(|x| x.into()),
)
.boxed()
}
fn as_arc(&mut self) -> Arc<dyn Array> {
PrimitiveArray::new(
self.data_type.clone(),
std::mem::take(&mut self.values).into(),
std::mem::take(&mut self.validity).map(|x| x.into()),
)
.arced()
}
fn data_type(&self) -> &DataType {
&self.data_type
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_mut_any(&mut self) -> &mut dyn std::any::Any {
self
}
fn push_null(&mut self) {
self.push(None)
}
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
fn try_push_valid<T: Hash>(&mut self, value: &T) -> Result<bool> {
let mut hasher = DefaultHasher::new();
value.hash(&mut hasher);
let hash = hasher.finish();
match self.map.get(&hash) {
Some(key) => {
self.keys.push(Some(*key));
Ok(false)
}
None => {
let key = K::try_from(self.map.len()).map_err(|_| Error::Overflow)?;
self.map.insert(hash, key);
self.keys.push(Some(key));
Ok(true)
}
}
}
/// pushes a null value
pub fn push_null(&mut self) {
self.keys.push(None)
}
/// returns a mutable reference to the inner values.
fn mut_values(&mut self) -> &mut M {
&mut self.values
}
/// returns a reference to the inner values.
pub fn values(&self) -> &M {
&self.values
}
/// converts itself into [`Arc<dyn Array>`]
pub fn into_arc(self) -> Arc<dyn Array> {
let a: DictionaryArray<K> = self.into();
Arc::new(a)
}
/// converts itself into [`Box<dyn Array>`]
pub fn into_box(self) -> Box<dyn Array> {
let a: DictionaryArray<K> = self.into();
Box::new(a)
}
/// Reserves `additional` slots.
pub fn reserve(&mut self, additional: usize) {
self.keys.reserve(additional);
}
/// Shrinks the capacity of the [`MutableDictionaryArray`] to fit its current length.
pub fn shrink_to_fit(&mut self) {
self.values.shrink_to_fit();
self.keys.shrink_to_fit();
}
/// Returns the dictionary map
pub fn map(&self) -> &HashedMap<u64, K> {
&self.map
}
/// Returns the dictionary keys
pub fn keys(&self) -> &MutablePrimitiveArray<K> {
&self.keys
}
fn take_into(&mut self) -> DictionaryArray<K> {
DictionaryArray::<K>::try_new(
self.data_type.clone(),
std::mem::take(&mut self.keys).into(),
self.values.as_box(),
)
.unwrap()
}
}
impl<K: DictionaryKey, M: 'static + MutableArray> MutableArray for MutableDictionaryArray<K, M> {
fn len(&self) -> usize {
self.keys.len()
}
fn validity(&self) -> Option<&MutableBitmap> {
self.keys.validity()
}
fn as_box(&mut self) -> Box<dyn Array> {
Box::new(self.take_into())
}
fn as_arc(&mut self) -> Arc<dyn Array> {
Arc::new(self.take_into())
}
fn data_type(&self) -> &DataType {
&self.data_type
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_mut_any(&mut self) -> &mut dyn std::any::Any {
self
}
fn push_null(&mut self) {
self.keys.push(None)
}
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
pub(super) fn push_i128(
from: Option<&dyn ParquetStatistics>,
n: usize,
min: &mut dyn MutableArray,
max: &mut dyn MutableArray,
) -> Result<()> {
let min = min
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<i128>>()
.unwrap();
let max = max
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<i128>>()
.unwrap();
let from = from.map(|s| s.as_any().downcast_ref::<FixedLenStatistics>().unwrap());
min.push(from.and_then(|s| s.min_value.as_deref().map(|x| convert_i128(x, n))));
max.push(from.and_then(|s| s.max_value.as_deref().map(|x| convert_i128(x, n))));
Ok(())
}
pub(super) fn push(
from: Option<&dyn ParquetStatistics>,
min: &mut dyn MutableArray,
max: &mut dyn MutableArray,
) -> Result<()> {
let min = min
.as_mut_any()
.downcast_mut::<MutableFixedSizeBinaryArray>()
.unwrap();
let max = max
.as_mut_any()
.downcast_mut::<MutableFixedSizeBinaryArray>()
.unwrap();
let from = from.map(|s| s.as_any().downcast_ref::<FixedLenStatistics>().unwrap());
min.push(from.and_then(|s| s.min_value.as_ref()));
max.push(from.and_then(|s| s.max_value.as_ref()));
Ok(())
}
fn convert_year_month(value: &[u8]) -> i32 {
i32::from_le_bytes(value[..4].try_into().unwrap())
}
pub(super) fn push_year_month(
from: Option<&dyn ParquetStatistics>,
min: &mut dyn MutableArray,
max: &mut dyn MutableArray,
) -> Result<()> {
let min = min
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<i32>>()
.unwrap();
let max = max
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<i32>>()
.unwrap();
let from = from.map(|s| s.as_any().downcast_ref::<FixedLenStatistics>().unwrap());
min.push(from.and_then(|s| s.min_value.as_deref().map(convert_year_month)));
max.push(from.and_then(|s| s.max_value.as_deref().map(convert_year_month)));
Ok(())
}
pub(super) fn push_days_ms(
from: Option<&dyn ParquetStatistics>,
min: &mut dyn MutableArray,
max: &mut dyn MutableArray,
) -> Result<()> {
let min = min
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<days_ms>>()
.unwrap();
let max = max
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<days_ms>>()
.unwrap();
let from = from.map(|s| s.as_any().downcast_ref::<FixedLenStatistics>().unwrap());
min.push(from.and_then(|s| s.min_value.as_deref().map(convert_days_ms)));
max.push(from.and_then(|s| s.max_value.as_deref().map(convert_days_ms)));
Ok(())
}
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
pub(super) fn push<P: ParquetNativeType, T: NativeType, F: Fn(P) -> Result<T> + Copy>(
from: Option<&dyn ParquetStatistics>,
min: &mut dyn MutableArray,
max: &mut dyn MutableArray,
map: F,
) -> Result<()> {
let min = min
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<T>>()
.unwrap();
let max = max
.as_mut_any()
.downcast_mut::<MutablePrimitiveArray<T>>()
.unwrap();
let from = from.map(|s| s.as_any().downcast_ref::<PrimitiveStatistics<P>>().unwrap());
min.push(from.and_then(|s| s.min_value.map(map)).transpose()?);
max.push(from.and_then(|s| s.max_value.map(map)).transpose()?);
Ok(())
}
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
fn push_others(
from: Option<&dyn ParquetStatistics>,
distinct_count: &mut UInt64Vec,
null_count: &mut UInt64Vec,
) {
let from = if let Some(from) = from {
from
} else {
distinct_count.push(None);
null_count.push(None);
return;
};
let (distinct, null_count1) = match from.physical_type() {
ParquetPhysicalType::Boolean => {
let from = from.as_any().downcast_ref::<BooleanStatistics>().unwrap();
(from.distinct_count, from.null_count)
}
ParquetPhysicalType::Int32 => {
let from = from
.as_any()
.downcast_ref::<PrimitiveStatistics<i32>>()
.unwrap();
(from.distinct_count, from.null_count)
}
ParquetPhysicalType::Int64 => {
let from = from
.as_any()
.downcast_ref::<PrimitiveStatistics<i64>>()
.unwrap();
(from.distinct_count, from.null_count)
}
ParquetPhysicalType::Int96 => {
let from = from
.as_any()
.downcast_ref::<PrimitiveStatistics<[u32; 3]>>()
.unwrap();
(from.distinct_count, from.null_count)
}
ParquetPhysicalType::Float => {
let from = from
.as_any()
.downcast_ref::<PrimitiveStatistics<f32>>()
.unwrap();
(from.distinct_count, from.null_count)
}
ParquetPhysicalType::Double => {
let from = from
.as_any()
.downcast_ref::<PrimitiveStatistics<f64>>()
.unwrap();
(from.distinct_count, from.null_count)
}
ParquetPhysicalType::ByteArray => {
let from = from.as_any().downcast_ref::<BinaryStatistics>().unwrap();
(from.distinct_count, from.null_count)
}
ParquetPhysicalType::FixedLenByteArray(_) => {
let from = from.as_any().downcast_ref::<FixedLenStatistics>().unwrap();
(from.distinct_count, from.null_count)
}
};
distinct_count.push(distinct.map(|x| x as u64));
null_count.push(null_count1.map(|x| x as u64));
}
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Pop a value from the array. Note if the values is empty, this method will return None.
sourcepub fn extend_constant(&mut self, additional: usize, value: Option<T>)
pub fn extend_constant(&mut self, additional: usize, value: Option<T>)
Extends the MutablePrimitiveArray
with a constant
sourcepub fn extend_trusted_len<P, I>(&mut self, iterator: I)where
P: Borrow<T>,
I: TrustedLen<Item = Option<P>>,
pub fn extend_trusted_len<P, I>(&mut self, iterator: I)where
P: Borrow<T>,
I: TrustedLen<Item = Option<P>>,
Extends the MutablePrimitiveArray
from an iterator of trusted len.
Examples found in repository?
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
fn deserialize_int_into<
'a,
T: NativeType + lexical_core::FromLexical + Pow10,
A: Borrow<Value<'a>>,
>(
target: &mut MutablePrimitiveArray<T>,
rows: &[A],
) {
let iter = rows.iter().map(|row| match row.borrow() {
Value::Number(number) => Some(deserialize_int_single(*number)),
Value::Bool(number) => Some(if *number { T::one() } else { T::default() }),
_ => None,
});
target.extend_trusted_len(iter);
}
fn deserialize_float_into<
'a,
T: NativeType + lexical_core::FromLexical + Powi10,
A: Borrow<Value<'a>>,
>(
target: &mut MutablePrimitiveArray<T>,
rows: &[A],
) {
let iter = rows.iter().map(|row| match row.borrow() {
Value::Number(number) => Some(deserialize_float_single(number)),
Value::Bool(number) => Some(if *number { T::one() } else { T::default() }),
_ => None,
});
target.extend_trusted_len(iter);
}
sourcepub unsafe fn extend_trusted_len_unchecked<P, I>(&mut self, iterator: I)where
P: Borrow<T>,
I: Iterator<Item = Option<P>>,
pub unsafe fn extend_trusted_len_unchecked<P, I>(&mut self, iterator: I)where
P: Borrow<T>,
I: Iterator<Item = Option<P>>,
Extends the MutablePrimitiveArray
from an iterator of trusted len.
Safety
The iterator must be trusted len.
sourcepub fn extend_trusted_len_values<I>(&mut self, iterator: I)where
I: TrustedLen<Item = T>,
pub fn extend_trusted_len_values<I>(&mut self, iterator: I)where
I: TrustedLen<Item = T>,
Extends the MutablePrimitiveArray
from an iterator of values of trusted len.
This differs from extend_trusted_len
which accepts in iterator of optional values.
sourcepub unsafe fn extend_trusted_len_values_unchecked<I>(&mut self, iterator: I)where
I: Iterator<Item = T>,
pub unsafe fn extend_trusted_len_values_unchecked<I>(&mut self, iterator: I)where
I: Iterator<Item = T>,
Extends the MutablePrimitiveArray
from an iterator of values of trusted len.
This differs from extend_trusted_len_unchecked
which accepts in iterator of optional values.
Safety
The iterator must be trusted len.
sourcepub fn extend_from_slice(&mut self, items: &[T])
pub fn extend_from_slice(&mut self, items: &[T])
Extends the MutablePrimitiveArray
from a slice
sourcepub fn to(self, data_type: DataType) -> Self
pub fn to(self, data_type: DataType) -> Self
Changes the arrays’ DataType
, returning a new MutablePrimitiveArray
.
Use to change the logical type without changing the corresponding physical Type.
Implementation
This operation is O(1)
.
Examples found in repository?
437 438 439 440 441 442 443 444 445 446 447 448 449
fn fill_array_from<B, T, A>(
f: fn(&mut MutablePrimitiveArray<T>, &[B]),
data_type: DataType,
rows: &[B],
) -> Box<dyn Array>
where
T: NativeType,
A: From<MutablePrimitiveArray<T>> + Array,
{
let mut array = MutablePrimitiveArray::<T>::with_capacity(rows.len()).to(data_type);
f(&mut array, rows);
Box::new(A::from(array))
}
More examples
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
fn deserialize_int64<I: TrustedLen<Item = Option<i64>>>(
iter: I,
primitive_type: &PrimitiveType,
data_type: DataType,
) -> Box<dyn Array> {
use DataType::*;
match data_type.to_logical_type() {
UInt64 => Box::new(
PrimitiveArray::<u64>::from_trusted_len_iter(iter.map(|x| x.map(|x| x as u64)))
.to(data_type),
) as _,
Decimal(_, _) => Box::new(
PrimitiveArray::<i128>::from_trusted_len_iter(iter.map(|x| x.map(|x| x as i128)))
.to(data_type),
) as _,
Timestamp(time_unit, _) => {
let mut array =
MutablePrimitiveArray::<i64>::from_trusted_len_iter(iter).to(data_type.clone());
timestamp(&mut array, *time_unit, primitive_type.logical_type);
let array: PrimitiveArray<i64> = array.into();
Box::new(array)
}
_ => Box::new(PrimitiveArray::<i64>::from_trusted_len_iter(iter).to(data_type)),
}
}
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the MutablePrimitiveArray
to fit its current length.
Examples found in repository?
More examples
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity of this MutablePrimitiveArray
.
source§impl<T: NativeType> MutablePrimitiveArray<T>
impl<T: NativeType> MutablePrimitiveArray<T>
Accessors
sourcepub fn values(&self) -> &Vec<T> ⓘ
pub fn values(&self) -> &Vec<T> ⓘ
Returns its values.
Examples found in repository?
38 39 40 41 42 43 44 45 46 47 48 49
pub fn iter(&'a self) -> ZipValidity<&'a T, std::slice::Iter<'a, T>, BitmapIter<'a>> {
ZipValidity::new(
self.values().iter(),
self.validity().as_ref().map(|x| x.iter()),
)
}
/// Returns an iterator of `T`
#[inline]
pub fn values_iter(&'a self) -> std::slice::Iter<'a, T> {
self.values().iter()
}
sourcepub fn values_mut_slice(&mut self) -> &mut [T] ⓘ
pub fn values_mut_slice(&mut self) -> &mut [T] ⓘ
Returns a mutable slice of values.
Examples found in repository?
43 44 45 46 47 48 49 50 51 52 53 54 55
fn op<T, I, F>(iter: I, op: F) -> impl Iterator<Item = Result<PrimitiveArray<T>>>
where
T: NativeType,
I: Iterator<Item = Result<MutablePrimitiveArray<T>>>,
F: Fn(T) -> T + Copy,
{
iter.map(move |x| {
x.map(move |mut x| {
x.values_mut_slice().iter_mut().for_each(|x| *x = op(*x));
x.into()
})
})
}
More examples
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn timestamp(
array: &mut MutablePrimitiveArray<i64>,
time_unit: TimeUnit,
logical_type: Option<PrimitiveLogicalType>,
) {
let unit = if let Some(PrimitiveLogicalType::Timestamp { unit, .. }) = logical_type {
unit
} else {
return;
};
match (unit, time_unit) {
(ParquetTimeUnit::Milliseconds, TimeUnit::Second) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x /= 1_000),
(ParquetTimeUnit::Microseconds, TimeUnit::Second) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x /= 1_000_000),
(ParquetTimeUnit::Nanoseconds, TimeUnit::Second) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x /= 1_000_000_000),
(ParquetTimeUnit::Milliseconds, TimeUnit::Millisecond) => {}
(ParquetTimeUnit::Microseconds, TimeUnit::Millisecond) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x /= 1_000),
(ParquetTimeUnit::Nanoseconds, TimeUnit::Millisecond) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x /= 1_000_000),
(ParquetTimeUnit::Milliseconds, TimeUnit::Microsecond) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x *= 1_000),
(ParquetTimeUnit::Microseconds, TimeUnit::Microsecond) => {}
(ParquetTimeUnit::Nanoseconds, TimeUnit::Microsecond) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x /= 1_000),
(ParquetTimeUnit::Milliseconds, TimeUnit::Nanosecond) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x *= 1_000_000),
(ParquetTimeUnit::Microseconds, TimeUnit::Nanosecond) => array
.values_mut_slice()
.iter_mut()
.for_each(|x| *x /= 1_000),
(ParquetTimeUnit::Nanoseconds, TimeUnit::Nanosecond) => {}
}
}
source§impl<T: NativeType> MutablePrimitiveArray<T>
impl<T: NativeType> MutablePrimitiveArray<T>
Setters
sourcepub fn set(&mut self, index: usize, value: Option<T>)
pub fn set(&mut self, index: usize, value: Option<T>)
Sets position index
to value
.
Note that if it is the first time a null appears in this array,
this initializes the validity bitmap (O(N)
).
Panic
Panics iff index is larger than self.len()
.
sourcepub unsafe fn set_unchecked(&mut self, index: usize, value: Option<T>)
pub unsafe fn set_unchecked(&mut self, index: usize, value: Option<T>)
Sets position index
to value
.
Note that if it is the first time a null appears in this array,
this initializes the validity bitmap (O(N)
).
Safety
Caller must ensure index < self.len()
sourcepub fn set_validity(&mut self, validity: Option<MutableBitmap>)
pub fn set_validity(&mut self, validity: Option<MutableBitmap>)
sourcepub fn set_values(&mut self, values: Vec<T>)
pub fn set_values(&mut self, values: Vec<T>)
source§impl<T: NativeType> MutablePrimitiveArray<T>
impl<T: NativeType> MutablePrimitiveArray<T>
sourcepub fn from_slice<P: AsRef<[T]>>(slice: P) -> Self
pub fn from_slice<P: AsRef<[T]>>(slice: P) -> Self
Creates a MutablePrimitiveArray
from a slice of values.
sourcepub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Selfwhere
P: Borrow<T>,
I: Iterator<Item = Option<P>>,
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Selfwhere
P: Borrow<T>,
I: Iterator<Item = Option<P>>,
Creates a MutablePrimitiveArray
from an iterator of trusted length.
Safety
The iterator must be TrustedLen
.
I.e. size_hint().1
correctly reports its length.
Examples found in repository?
More examples
sourcepub fn from_trusted_len_iter<I, P>(iterator: I) -> Selfwhere
P: Borrow<T>,
I: TrustedLen<Item = Option<P>>,
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Selfwhere
P: Borrow<T>,
I: TrustedLen<Item = Option<P>>,
Creates a MutablePrimitiveArray
from a TrustedLen
.
Examples found in repository?
More examples
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
fn deserialize_int64<I: TrustedLen<Item = Option<i64>>>(
iter: I,
primitive_type: &PrimitiveType,
data_type: DataType,
) -> Box<dyn Array> {
use DataType::*;
match data_type.to_logical_type() {
UInt64 => Box::new(
PrimitiveArray::<u64>::from_trusted_len_iter(iter.map(|x| x.map(|x| x as u64)))
.to(data_type),
) as _,
Decimal(_, _) => Box::new(
PrimitiveArray::<i128>::from_trusted_len_iter(iter.map(|x| x.map(|x| x as i128)))
.to(data_type),
) as _,
Timestamp(time_unit, _) => {
let mut array =
MutablePrimitiveArray::<i64>::from_trusted_len_iter(iter).to(data_type.clone());
timestamp(&mut array, *time_unit, primitive_type.logical_type);
let array: PrimitiveArray<i64> = array.into();
Box::new(array)
}
_ => Box::new(PrimitiveArray::<i64>::from_trusted_len_iter(iter).to(data_type)),
}
}
sourcepub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iter: I
) -> Result<Self, E>where
P: Borrow<T>,
I: IntoIterator<Item = Result<Option<P>, E>>,
pub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iter: I
) -> Result<Self, E>where
P: Borrow<T>,
I: IntoIterator<Item = Result<Option<P>, E>>,
Creates a MutablePrimitiveArray
from an fallible iterator of trusted length.
Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
sourcepub fn try_from_trusted_len_iter<E, I, P>(iterator: I) -> Result<Self, E>where
P: Borrow<T>,
I: TrustedLen<Item = Result<Option<P>, E>>,
pub fn try_from_trusted_len_iter<E, I, P>(iterator: I) -> Result<Self, E>where
P: Borrow<T>,
I: TrustedLen<Item = Result<Option<P>, E>>,
Creates a MutablePrimitiveArray
from an fallible iterator of trusted length.
sourcepub fn from_trusted_len_values_iter<I: TrustedLen<Item = T>>(iter: I) -> Self
pub fn from_trusted_len_values_iter<I: TrustedLen<Item = T>>(iter: I) -> Self
Creates a new MutablePrimitiveArray
out an iterator over values
Examples found in repository?
More examples
sourcepub fn from_vec(values: Vec<T>) -> Self
pub fn from_vec(values: Vec<T>) -> Self
Creates a (non-null) MutablePrimitiveArray
from a vector of values.
This does not have memcopy and is the fastest way to create a PrimitiveArray
.
sourcepub unsafe fn from_trusted_len_values_iter_unchecked<I: Iterator<Item = T>>(
iter: I
) -> Self
pub unsafe fn from_trusted_len_values_iter_unchecked<I: Iterator<Item = T>>(
iter: I
) -> Self
Creates a new MutablePrimitiveArray
from an iterator over values
Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
Trait Implementations§
source§impl<T: Clone + NativeType> Clone for MutablePrimitiveArray<T>
impl<T: Clone + NativeType> Clone for MutablePrimitiveArray<T>
source§fn clone(&self) -> MutablePrimitiveArray<T>
fn clone(&self) -> MutablePrimitiveArray<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug + NativeType> Debug for MutablePrimitiveArray<T>
impl<T: Debug + NativeType> Debug for MutablePrimitiveArray<T>
source§impl<T: NativeType> Default for MutablePrimitiveArray<T>
impl<T: NativeType> Default for MutablePrimitiveArray<T>
source§impl<T: NativeType> Extend<Option<T>> for MutablePrimitiveArray<T>
impl<T: NativeType> Extend<Option<T>> for MutablePrimitiveArray<T>
source§fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<T: NativeType> From<DataType> for MutablePrimitiveArray<T>
impl<T: NativeType> From<DataType> for MutablePrimitiveArray<T>
source§impl<T: NativeType> From<MutablePrimitiveArray<T>> for PrimitiveArray<T>
impl<T: NativeType> From<MutablePrimitiveArray<T>> for PrimitiveArray<T>
source§fn from(other: MutablePrimitiveArray<T>) -> Self
fn from(other: MutablePrimitiveArray<T>) -> Self
source§impl<T: NativeType, P: AsRef<[Option<T>]>> From<P> for MutablePrimitiveArray<T>
impl<T: NativeType, P: AsRef<[Option<T>]>> From<P> for MutablePrimitiveArray<T>
source§impl<T: NativeType, Ptr: Borrow<Option<T>>> FromIterator<Ptr> for MutablePrimitiveArray<T>
impl<T: NativeType, Ptr: Borrow<Option<T>>> FromIterator<Ptr> for MutablePrimitiveArray<T>
source§fn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self
source§impl<T: NativeType> MutableArray for MutablePrimitiveArray<T>
impl<T: NativeType> MutableArray for MutablePrimitiveArray<T>
source§fn validity(&self) -> Option<&MutableBitmap>
fn validity(&self) -> Option<&MutableBitmap>
source§fn as_arc(&mut self) -> Arc<dyn Array>
fn as_arc(&mut self) -> Arc<dyn Array>
Array
.source§fn as_mut_any(&mut self) -> &mut dyn Any
fn as_mut_any(&mut self) -> &mut dyn Any
Any
, to enable dynamic casting.source§fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
source§impl<T: NativeType> PartialEq<MutablePrimitiveArray<T>> for MutablePrimitiveArray<T>
impl<T: NativeType> PartialEq<MutablePrimitiveArray<T>> for MutablePrimitiveArray<T>
source§impl<T: NativeType> TryExtend<Option<T>> for MutablePrimitiveArray<T>
impl<T: NativeType> TryExtend<Option<T>> for MutablePrimitiveArray<T>
source§fn try_extend<I: IntoIterator<Item = Option<T>>>(
&mut self,
iter: I
) -> Result<(), Error>
fn try_extend<I: IntoIterator<Item = Option<T>>>(
&mut self,
iter: I
) -> Result<(), Error>
This is infalible and is implemented for consistency with all other types