-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move invert from BoolArrayTrait to InvertFn (#1490)
- Loading branch information
Showing
26 changed files
with
223 additions
and
128 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,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()) | ||
} | ||
} |
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,18 @@ | ||
use vortex_array::compute::{invert, InvertFn}; | ||
use vortex_array::{ArrayData, ArrayLen, IntoArrayData}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::{RunEndArray, RunEndEncoding}; | ||
|
||
impl InvertFn<RunEndArray> for RunEndEncoding { | ||
fn invert(&self, array: &RunEndArray) -> VortexResult<ArrayData> { | ||
RunEndArray::with_offset_and_length( | ||
array.ends(), | ||
invert(&array.values())?, | ||
array.validity(), | ||
array.len(), | ||
array.offset(), | ||
) | ||
.map(|a| a.into_array()) | ||
} | ||
} |
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,13 @@ | ||
use std::ops::Not; | ||
|
||
use vortex_error::VortexResult; | ||
|
||
use crate::array::{BoolArray, BoolEncoding}; | ||
use crate::compute::InvertFn; | ||
use crate::{ArrayData, IntoArrayData}; | ||
|
||
impl InvertFn<BoolArray> for BoolEncoding { | ||
fn invert(&self, array: &BoolArray) -> VortexResult<ArrayData> { | ||
Ok(BoolArray::try_new(array.boolean_buffer().not(), array.validity())?.into_array()) | ||
} | ||
} |
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,13 @@ | ||
use itertools::Itertools; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::array::{ChunkedArray, ChunkedEncoding}; | ||
use crate::compute::{invert, InvertFn}; | ||
use crate::{ArrayDType, ArrayData, IntoArrayData}; | ||
|
||
impl InvertFn<ChunkedArray> for ChunkedEncoding { | ||
fn invert(&self, array: &ChunkedArray) -> VortexResult<ArrayData> { | ||
let chunks = array.chunks().map(|c| invert(&c)).try_collect()?; | ||
ChunkedArray::try_new(chunks, array.dtype().clone()).map(|a| a.into_array()) | ||
} | ||
} |
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,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()), | ||
} | ||
} | ||
} |
Oops, something went wrong.