1
2
3
4
5
6
7
8
9
10
11
12
13
14
use vortex_error::VortexResult;

use crate::array::{ConstantArray, ConstantEncoding};
use crate::compute::InvertFn;
use crate::{ArrayData, ArrayLen, IntoArrayData, ToArrayData};

impl InvertFn<ConstantArray> for ConstantEncoding {
    fn invert(&self, array: &ConstantArray) -> VortexResult<ArrayData> {
        match array.scalar().as_bool().value() {
            None => Ok(array.to_array()),
            Some(b) => Ok(ConstantArray::new(!b, array.len()).into_array()),
        }
    }
}