1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use vortex_array::compute::InvertFn;
use vortex_array::{ArrayData, ArrayLen, IntoArrayData};
use vortex_error::VortexResult;

use crate::{RunEndBoolArray, RunEndBoolEncoding};

impl InvertFn<RunEndBoolArray> for RunEndBoolEncoding {
    fn invert(&self, array: &RunEndBoolArray) -> VortexResult<ArrayData> {
        RunEndBoolArray::with_offset_and_size(
            array.ends(),
            // We only need to invert the starting bool
            !array.start(),
            array.validity(),
            array.len(),
            array.offset(),
        )
        .map(|a| a.into_array())
    }
}