-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use filter in RowMask::evaluate (#1515)
- Loading branch information
Showing
12 changed files
with
146 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use vortex_array::compute::{filter, FilterFn, FilterMask}; | ||
use vortex_array::{ArrayDType, ArrayData, IntoArrayData}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::{DateTimePartsArray, DateTimePartsEncoding}; | ||
|
||
impl FilterFn<DateTimePartsArray> for DateTimePartsEncoding { | ||
fn filter(&self, array: &DateTimePartsArray, mask: FilterMask) -> VortexResult<ArrayData> { | ||
Ok(DateTimePartsArray::try_new( | ||
array.dtype().clone(), | ||
filter(array.days().as_ref(), mask.clone())?, | ||
filter(array.seconds().as_ref(), mask.clone())?, | ||
filter(array.subsecond().as_ref(), mask)?, | ||
)? | ||
.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,22 @@ | ||
use vortex_array::compute::{take, TakeFn, TakeOptions}; | ||
use vortex_array::{ArrayDType, ArrayData, IntoArrayData}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::{DateTimePartsArray, DateTimePartsEncoding}; | ||
|
||
impl TakeFn<DateTimePartsArray> for DateTimePartsEncoding { | ||
fn take( | ||
&self, | ||
array: &DateTimePartsArray, | ||
indices: &ArrayData, | ||
options: TakeOptions, | ||
) -> VortexResult<ArrayData> { | ||
Ok(DateTimePartsArray::try_new( | ||
array.dtype().clone(), | ||
take(array.days(), indices, options)?, | ||
take(array.seconds(), indices, options)?, | ||
take(array.subsecond(), indices, options)?, | ||
)? | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use vortex_dtype::{DType, Nullability}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::array::{ChunkedArray, ChunkedEncoding}; | ||
use crate::compute::{and, and_kleene, or, or_kleene, slice, BinaryBooleanFn, BinaryOperator}; | ||
use crate::{ArrayData, IntoArrayData}; | ||
|
||
impl BinaryBooleanFn<ChunkedArray> for ChunkedEncoding { | ||
fn binary_boolean( | ||
&self, | ||
lhs: &ChunkedArray, | ||
rhs: &ArrayData, | ||
op: BinaryOperator, | ||
) -> VortexResult<Option<ArrayData>> { | ||
let mut idx = 0; | ||
let mut chunks = Vec::with_capacity(lhs.nchunks()); | ||
|
||
for chunk in lhs.chunks() { | ||
let sliced = slice(rhs, idx, idx + chunk.len())?; | ||
let result = match op { | ||
BinaryOperator::And => and(&chunk, &sliced), | ||
BinaryOperator::AndKleene => and_kleene(&chunk, &sliced), | ||
BinaryOperator::Or => or(&chunk, &sliced), | ||
BinaryOperator::OrKleene => or_kleene(&chunk, &sliced), | ||
}; | ||
chunks.push(result?); | ||
idx += chunk.len(); | ||
} | ||
|
||
Ok(Some( | ||
ChunkedArray::try_new(chunks, DType::Bool(Nullability::Nullable))?.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use vortex_dtype::{DType, Nullability}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::array::{ChunkedArray, ChunkedEncoding}; | ||
use crate::compute::{compare, slice, CompareFn, Operator}; | ||
use crate::{ArrayData, IntoArrayData}; | ||
|
||
impl CompareFn<ChunkedArray> for ChunkedEncoding { | ||
fn compare( | ||
&self, | ||
lhs: &ChunkedArray, | ||
rhs: &ArrayData, | ||
operator: Operator, | ||
) -> VortexResult<Option<ArrayData>> { | ||
let mut idx = 0; | ||
let mut compare_chunks = Vec::with_capacity(lhs.nchunks()); | ||
|
||
for chunk in lhs.chunks() { | ||
let sliced = slice(rhs, idx, idx + chunk.len())?; | ||
let cmp_result = compare(&chunk, &sliced, operator)?; | ||
compare_chunks.push(cmp_result); | ||
|
||
idx += chunk.len(); | ||
} | ||
|
||
Ok(Some( | ||
ChunkedArray::try_new(compare_chunks, DType::Bool(Nullability::Nullable))?.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
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