Struct ScalarZipper
pub struct ScalarZipper {
zip_impl: Arc<dyn ZipImpl>,
}Expand description
Zipper for 2 scalars
Useful for using in IF <expr> THEN <scalar> ELSE <scalar> END expressions
§Example
let scalar_truthy = Scalar::new(Int32Array::from_value(42, 1));
let scalar_falsy = Scalar::new(Int32Array::from_value(123, 1));
let zipper = ScalarZipper::try_new(&scalar_truthy, &scalar_falsy).unwrap();
// Later when we have a boolean mask
let mask = BooleanArray::from(vec![true, false, true, false, true]);
let result = zipper.zip(&mask).unwrap();
let actual = result.as_primitive::<Int32Type>();
let expected = Int32Array::from(vec![Some(42), Some(123), Some(42), Some(123), Some(42)]);Fields§
§zip_impl: Arc<dyn ZipImpl>Implementations§
§impl ScalarZipper
impl ScalarZipper
pub fn try_new(
truthy: &dyn Datum,
falsy: &dyn Datum,
) -> Result<ScalarZipper, ArrowError>
pub fn try_new( truthy: &dyn Datum, falsy: &dyn Datum, ) -> Result<ScalarZipper, ArrowError>
Try to create a new ScalarZipper from two scalar Datum
§Errors
returns error if:
- the two Datum have different data types
- either Datum is not a scalar (or has more than 1 element)
pub fn zip(&self, mask: &BooleanArray) -> Result<Arc<dyn Array>, ArrowError>
pub fn zip(&self, mask: &BooleanArray) -> Result<Arc<dyn Array>, ArrowError>
Creating output array based on input boolean array and the two scalar values the zipper was created with See struct level documentation for examples.
Trait Implementations§
§impl Clone for ScalarZipper
impl Clone for ScalarZipper
§fn clone(&self) -> ScalarZipper
fn clone(&self) -> ScalarZipper
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ScalarZipper
impl !RefUnwindSafe for ScalarZipper
impl Send for ScalarZipper
impl Sync for ScalarZipper
impl Unpin for ScalarZipper
impl !UnwindSafe for ScalarZipper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more