Skip to content

Commit

Permalink
Binary Boolean VTable (#1407)
Browse files Browse the repository at this point in the history
* Also merged all binary boolean functions since they're trivial to
implement if you implement one of them.
* And switched over to similar semantics as CompareFn where an encoding
gets to see the arguments before deciding if they're supported.

FLUP: we weren't short-circuiting boolean operations if one of the sides
was constant.
  • Loading branch information
gatesn authored Nov 20, 2024
1 parent 983ed67 commit dddf5f2
Show file tree
Hide file tree
Showing 9 changed files with 480 additions and 499 deletions.
4 changes: 0 additions & 4 deletions bench-vortex/src/bin/notimplemented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ fn compute_funcs(encodings: &[ArrayData]) {
"search_sorted",
"slice",
"take",
"and",
"or",
]
.into_iter()
.map(Cell::new)
Expand All @@ -207,8 +205,6 @@ fn compute_funcs(encodings: &[ArrayData]) {
impls.push(bool_to_cell(arr.with_dyn(|a| a.search_sorted().is_some())));
impls.push(bool_to_cell(arr.encoding().slice_fn().is_some()));
impls.push(bool_to_cell(arr.encoding().take_fn().is_some()));
impls.push(bool_to_cell(arr.with_dyn(|a| a.and().is_some())));
impls.push(bool_to_cell(arr.with_dyn(|a| a.or().is_some())));
table.add_row(Row::new(impls));
}
table.printstd();
Expand Down
48 changes: 0 additions & 48 deletions vortex-array/src/array/bool/compute/boolean.rs

This file was deleted.

24 changes: 13 additions & 11 deletions vortex-array/src/array/bool/compute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
use crate::array::{BoolArray, BoolEncoding};
use crate::compute::unary::{FillForwardFn, ScalarAtFn};
use crate::compute::{AndFn, ArrayCompute, ComputeVTable, FilterFn, OrFn, SliceFn, TakeFn};
use crate::compute::{ArrayCompute, BinaryBooleanFn, ComputeVTable, FilterFn, SliceFn, TakeFn};
use crate::ArrayData;

mod boolean;

mod fill;
pub mod filter;
mod flatten;
mod scalar_at;
mod slice;
mod take;

impl ArrayCompute for BoolArray {
fn and(&self) -> Option<&dyn AndFn> {
Some(self)
}
impl ArrayCompute for BoolArray {}

fn or(&self) -> Option<&dyn OrFn> {
Some(self)
impl ComputeVTable for BoolEncoding {
fn binary_boolean_fn(
&self,
_lhs: &ArrayData,
_rhs: &ArrayData,
) -> Option<&dyn BinaryBooleanFn<ArrayData>> {
// We only implement this when other is a constant value, otherwise we fall back to the
// default implementation that canonicalizes to Arrow.
// TODO(ngates): implement this for constants.
// other.is_constant().then_some(self)
None
}
}

impl ComputeVTable for BoolEncoding {
fn fill_forward_fn(&self) -> Option<&dyn FillForwardFn<ArrayData>> {
Some(self)
}
Expand Down
267 changes: 0 additions & 267 deletions vortex-array/src/array/constant/compute.rs

This file was deleted.

Loading

0 comments on commit dddf5f2

Please sign in to comment.