Skip to content

Commit

Permalink
Fix benchmarks (#762)
Browse files Browse the repository at this point in the history
I broke `PrimitiveArray::compare` in an earlier PR by introducing a
possibility of it returning a `NonNullable` result.
  • Loading branch information
AdamGS authored Sep 9, 2024
1 parent 35b24ac commit a106693
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vortex-array/src/array/primitive/compute/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl CompareFn for PrimitiveArray {
apply_predicate(self.maybe_null_slice::<$T>(), other.maybe_null_slice::<$T>(), operator.to_fn::<$T>())
});

let validity = self.validity().and(other.validity())?;
let validity = self.validity().and(other.validity())?.into_nullable();

Ok(BoolArray::try_new(match_mask, validity)?.into_array())
}
Expand Down
11 changes: 10 additions & 1 deletion vortex-array/src/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,15 @@ impl Validity {
/// Logically & two Validity values of the same length
pub fn and(self, rhs: Validity) -> VortexResult<Validity> {
let validity = match (&self, &rhs) {
// Should be pretty clear
(Validity::NonNullable, Validity::NonNullable) => Validity::NonNullable,
// Any `AllInvalid` makes the output all invalid values
(Validity::AllInvalid, _) | (_, Validity::AllInvalid) => Validity::AllInvalid,
// All truthy values on one side, which makes no effect on an `Array` variant
(Validity::Array(a), Validity::AllValid)
| (Validity::Array(a), Validity::NonNullable)
| (Validity::NonNullable, Validity::Array(a))
| (Validity::AllValid, Validity::Array(a)) => Validity::Array(a.clone()),
(Validity::NonNullable, Validity::NonNullable) => Validity::NonNullable,
// Both sides are all valid
(Validity::NonNullable, Validity::AllValid)
| (Validity::AllValid, Validity::NonNullable)
Expand All @@ -172,6 +173,14 @@ impl Validity {

Ok(validity)
}

/// Convert into a nullable variant
pub fn into_nullable(self) -> Validity {
match self {
Self::NonNullable => Self::AllValid,
_ => self,
}
}
}

impl PartialEq for Validity {
Expand Down

0 comments on commit a106693

Please sign in to comment.