pub fn or(lhs: &BooleanArray, rhs: &BooleanArray) -> Result<BooleanArray> {
    if lhs.len() != rhs.len() {
        return Err(ArrowError::InvalidArgumentError(
            "Cannot perform bitwise operation on arrays of different length".to_string(),
        ));
    }

    let lhs_values = lhs.values();
    let rhs_values = rhs.values();

    let lhs_validity = lhs.validity();
    let rhs_validity = rhs.validity();

    let validity = match (lhs_validity, rhs_validity) {
        (Some(lhs_validity), Some(rhs_validity)) => {
            Some(quaternary(
                lhs_values,
                rhs_values,
                lhs_validity,
                rhs_validity,
                // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics
                |lhs, rhs, lhs_v, rhs_v| {
                    // A = T
                    (lhs & lhs_v) |
                    // B = T
                    (rhs & rhs_v) |
                    // A = F & B = F
                    (!lhs & lhs_v) & (!rhs & rhs_v)
                },
            ))
        }
        (Some(lhs_validity), None) => {
            // B != U
            Some(ternary(
                lhs_values,
                rhs_values,
                lhs_validity,
                // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics
                |lhs, rhs, lhs_v| {
                    // A = T
                    (lhs & lhs_v) |
                    // B = T
                    rhs |
                    // A = F & B = F
                    (!lhs & lhs_v) & !rhs
                },
            ))
        }
        (None, Some(rhs_validity)) => {
            Some(ternary(
                lhs_values,
                rhs_values,
                rhs_validity,
                // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics
                |lhs, rhs, rhs_v| {
                    // A = T
                    lhs |
                    // B = T
                    (rhs & rhs_v) |
                    // A = F & B = F
                    !lhs & (!rhs & rhs_v)
                },
            ))
        }
        (None, None) => None,
    };
    Ok(BooleanArray::from_data(
        DataType::Boolean,
        lhs_values | rhs_values,
        validity,
    ))
}
/// Logical 'or' operation on two arrays with [Kleene logic](https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics)
/// # Errors
/// This function errors if the operands have different lengths.
/// # Example
///
/// ```rust
/// # use arrow2::error::Result;
/// use arrow2::array::BooleanArray;
/// use arrow2::compute::boolean_kleene::or;
/// # fn main() -> Result<()> {
/// let a = BooleanArray::from(&[Some(true), Some(false), None]);
/// let b = BooleanArray::from(&[None, None, None]);
/// let or_ab = or(&a, &b)?;
/// assert_eq!(or_ab, BooleanArray::from(&[Some(true), None, None]));
/// # Ok(())
/// # }
/// ```
Logical 'or' operation on two arrays with [Kleene logic]
Logical ' or ' operation on two arrays with [ Kleene logic ]
pub fn or(lhs: &BooleanArray, rhs: &BooleanArray) -> Result<BooleanArray> {
    if lhs.len() != rhs.len() {
        return Err(ArrowError::InvalidArgumentError(
            "Cannot perform bitwise operation on arrays of different length".to_string(),
        ));
    }
    let lhs_values = lhs.values();
    let rhs_values = rhs.values();
    let lhs_validity = lhs.validity();
    let rhs_validity = rhs.validity();
    let validity = match (lhs_validity, rhs_validity) {
        (Some(lhs_validity), Some(rhs_validity)) => {
            Some(quaternary(
                lhs_values,
                rhs_values,
                lhs_validity,
                rhs_validity,
                // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics
                |lhs, rhs, lhs_v, rhs_v| {
                    // A = T
                    (lhs & lhs_v) |
                    // B = T
                    (rhs & rhs_v) |
                    // A = F & B = F
                    (!lhs & lhs_v) & (!rhs & rhs_v)
                },
            ))
        }
        (Some(lhs_validity), None) => {
            // B != U
            Some(ternary(
                lhs_values,
                rhs_values,
                lhs_validity,
                // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics
                |lhs, rhs, lhs_v| {
                    // A = T
                    (lhs & lhs_v) |
                    // B = T
                    rhs |
                    // A = F & B = F
                    (!lhs & lhs_v) & !rhs
                },
            ))
        }
        (None, Some(rhs_validity)) => {
            Some(ternary(
                lhs_values,
                rhs_values,
                rhs_validity,
                // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics
                |lhs, rhs, rhs_v| {
                    // A = T
                    lhs |
                    // B = T
                    (rhs & rhs_v) |
                    // A = F & B = F
                    !lhs & (!rhs & rhs_v)
                },
            ))
        }
        (None, None) => None,
    };
    Ok(BooleanArray::from_data(
        DataType::Boolean,
        lhs_values | rhs_values,
        validity,
    ))
}
pub fn or ( lhs : & BooleanArray , rhs : & BooleanArray ) -> Result < BooleanArray > { if lhs . len ( ) != rhs . len ( ) { return Err ( ArrowError :: InvalidArgumentError ( " " . to_string ( ) , ) ) ; } let lhs_values = lhs . values ( ) ; let rhs_values = rhs . values ( ) ; let lhs_validity = lhs . validity ( ) ; let rhs_validity = rhs . validity ( ) ; let validity = match ( lhs_validity , rhs_validity ) { ( Some ( lhs_validity ) , Some ( rhs_validity ) ) => { Some ( quaternary ( lhs_values , rhs_values , lhs_validity , rhs_validity , // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics | lhs , rhs , lhs_v , rhs_v | { // A = T ( lhs & lhs_v ) | // B = T ( rhs & rhs_v ) | // A = F & B = F ( ! lhs & lhs_v ) & ( ! rhs & rhs_v ) } , ) ) } ( Some ( lhs_validity ) , None ) => { // B != U Some ( ternary ( lhs_values , rhs_values , lhs_validity , // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics | lhs , rhs , lhs_v | { // A = T ( lhs & lhs_v ) | // B = T rhs | // A = F & B = F ( ! lhs & lhs_v ) & ! rhs } , ) ) } ( None , Some ( rhs_validity ) ) => { Some ( ternary ( lhs_values , rhs_values , rhs_validity , // see https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics | lhs , rhs , rhs_v | { // A = T lhs | // B = T ( rhs & rhs_v ) | // A = F & B = F ! lhs & ( ! rhs & rhs_v ) } , ) ) } ( None , None ) => None , } ; Ok ( BooleanArray :: from_data ( DataType :: Boolean , lhs_values | rhs_values , validity , ) ) }
Logical 'or' operation on two arrays with [Kleene logic](https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics)
Logical ' or ' operation on two arrays with [ Kleene logic ] ( https : // en . wikipedia . org / wiki / Three - valued_logic#Kleene_and_Priest_logics )
lhs
&BooleanArray
rhs
&BooleanArray
lhs
&BooleanArray
rhs
&BooleanArray
errors
This function errors if the operands have different lengths.
This function errors if the operands have different lengths .
example
None
use arrow2::error::result;
use arrow2::array::BooleanArray;
use arrow2::compute::boolean_kleene::or.
use arrow2 :: array :: BooleanArray ; use arrow2 :: compute :: boolean_kleene :: or .
fn main() -> result<()> {
let a = BooleanArray::from(&[Some(true), Some(false), None]);
let b = BooleanArray::from(&[None, None, None]);
let or_ab = or(&a, &b)?;
assert_eq!(or_ab, BooleanArray::from(&[Some(true), None, None])).
let a = BooleanArray :: from ( & [ Some ( true ) Some ( false ) None ] ) ; let b = BooleanArray :: from ( & [ None None None ] ) ; let or_ab = or ( &a &b ) ? ; assert_eq! ( or_ab BooleanArray :: from ( & [ Some ( true ) None None ] )) .
ok(())
None
}
None