This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
BinaryArray::into_mut
and double-ended support for its iterat…
…or (#1255)
- Loading branch information
1 parent
4514cfc
commit 22f5568
Showing
6 changed files
with
261 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use arrow2::{array::BinaryArray, bitmap::Bitmap, buffer::Buffer, datatypes::DataType}; | ||
|
||
#[test] | ||
fn not_shared() { | ||
let array = BinaryArray::<i32>::from(&[Some("hello"), Some(" "), None]); | ||
assert!(array.into_mut().is_right()); | ||
} | ||
|
||
#[test] | ||
#[allow(clippy::redundant_clone)] | ||
fn shared_validity() { | ||
let validity = Bitmap::from([true]); | ||
let array = BinaryArray::<i32>::new( | ||
DataType::Binary, | ||
vec![0, 1].into(), | ||
b"a".to_vec().into(), | ||
Some(validity.clone()), | ||
); | ||
assert!(array.into_mut().is_left()) | ||
} | ||
|
||
#[test] | ||
#[allow(clippy::redundant_clone)] | ||
fn shared_values() { | ||
let values: Buffer<u8> = b"a".to_vec().into(); | ||
let array = BinaryArray::<i32>::new( | ||
DataType::Binary, | ||
vec![0, 1].into(), | ||
values.clone(), | ||
Some(Bitmap::from([true])), | ||
); | ||
assert!(array.into_mut().is_left()) | ||
} | ||
|
||
#[test] | ||
#[allow(clippy::redundant_clone)] | ||
fn shared_offsets_values() { | ||
let offsets: Buffer<i32> = vec![0, 1].into(); | ||
let values: Buffer<u8> = b"a".to_vec().into(); | ||
let array = BinaryArray::<i32>::new( | ||
DataType::Binary, | ||
offsets.clone(), | ||
values.clone(), | ||
Some(Bitmap::from([true])), | ||
); | ||
assert!(array.into_mut().is_left()) | ||
} | ||
|
||
#[test] | ||
#[allow(clippy::redundant_clone)] | ||
fn shared_offsets() { | ||
let offsets: Buffer<i32> = vec![0, 1].into(); | ||
let array = BinaryArray::<i32>::new( | ||
DataType::Binary, | ||
offsets.clone(), | ||
b"a".to_vec().into(), | ||
Some(Bitmap::from([true])), | ||
); | ||
assert!(array.into_mut().is_left()) | ||
} | ||
|
||
#[test] | ||
#[allow(clippy::redundant_clone)] | ||
fn shared_all() { | ||
let array = BinaryArray::<i32>::from(&[Some("hello"), Some(" "), None]); | ||
assert!(array.clone().into_mut().is_left()) | ||
} |