Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
add test and derive clone
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed May 18, 2022
1 parent 6891d08 commit f7c3daf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/array/primitive/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::PrimitiveArray;

/// 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)`.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct MutablePrimitiveArray<T: NativeType> {
data_type: DataType,
values: Vec<T>,
Expand Down
1 change: 1 addition & 0 deletions src/bitmap/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use super::Bitmap;
/// The main difference against [`Vec<bool>`] is that a bitmap cannot be represented as `&[bool]`.
/// # Implementation
/// This container is backed by [`Vec<u8>`].
#[derive(Clone)]
pub struct MutableBitmap {
buffer: Vec<u8>,
// invariant: length.saturating_add(7) / 8 == buffer.len();
Expand Down
6 changes: 6 additions & 0 deletions tests/it/array/primitive/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ fn set_validity() {
a.extend_trusted_len(vec![Some(1), Some(2)].into_iter());
let validity = a.validity().unwrap();
assert_eq!(validity.null_count(), 0);

// test that upon conversion to array the bitmap is set to None
let arr: PrimitiveArray<_> = a.clone().into();
assert_eq!(arr.validity(), None);

// test set_validity
a.set_validity(Some(MutableBitmap::from([false, true])));
assert_eq!(a.validity(), Some(&MutableBitmap::from([false, true])));
}
Expand Down

0 comments on commit f7c3daf

Please sign in to comment.