-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add BinaryNumericFn for array arithmetic (#1640)
I did not implement any binary numeric functions because it is not clear that there are any cases where we can out run decompression. Two run end arrays might be a happy path? Two dictionaries, maybe, if the dictionaries are much smaller than the decompressed arrays? Binary scalar numeric functions are more obviously valuable: clickbench includes several uses of scalar add or subtract.
- Loading branch information
Showing
23 changed files
with
570 additions
and
268 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
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,31 @@ | ||
use vortex_error::{vortex_err, VortexResult}; | ||
use vortex_scalar::BinaryNumericOperator; | ||
|
||
use crate::array::{ConstantArray, ConstantEncoding}; | ||
use crate::compute::BinaryNumericFn; | ||
use crate::{ArrayData, ArrayLen as _, IntoArrayData as _}; | ||
|
||
impl BinaryNumericFn<ConstantArray> for ConstantEncoding { | ||
fn binary_numeric( | ||
&self, | ||
array: &ConstantArray, | ||
rhs: &ArrayData, | ||
op: BinaryNumericOperator, | ||
) -> VortexResult<Option<ArrayData>> { | ||
let Some(rhs) = rhs.as_constant() else { | ||
return Ok(None); | ||
}; | ||
|
||
Ok(Some( | ||
ConstantArray::new( | ||
array | ||
.scalar() | ||
.as_primitive() | ||
.checked_numeric_operator(rhs.as_primitive(), op)? | ||
.ok_or_else(|| vortex_err!("numeric overflow"))?, | ||
array.len(), | ||
) | ||
.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
Oops, something went wrong.