Skip to content

Commit

Permalink
Remove to_present_null_buffer from LogicalValidity (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Aug 9, 2024
1 parent f614308 commit abb9eaa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
14 changes: 9 additions & 5 deletions vortex-array/src/array/primitive/compute/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ impl CompareFn for PrimitiveArray {
let present = self
.validity()
.to_logical(self.len())
.to_present_null_buffer()?
.into_inner();
.to_null_buffer()?
.map(|b| b.into_inner());
let present_other = flattened
.validity()
.to_logical(self.len())
.to_present_null_buffer()?
.into_inner();
.to_null_buffer()?
.map(|b| b.into_inner());

Ok(BoolArray::from(matching_idxs.bitand(&present).bitand(&present_other)).into_array())
let mut result = matching_idxs;
result = present.map(|p| p.bitand(&result)).unwrap_or(result);
result = present_other.map(|p| p.bitand(&result)).unwrap_or(result);

Ok(BoolArray::from(result).into_array())
}
}

Expand Down
9 changes: 6 additions & 3 deletions vortex-array/src/array/primitive/compute/filter_indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ impl FilterIndicesFn for PrimitiveArray {
let present_buf = self
.validity()
.to_logical(self.len())
.to_present_null_buffer()?
.into_inner();
.to_null_buffer()?
.map(|b| b.into_inner());

let bitset: VortexResult<BooleanBuffer> = conjunction_indices
.reduce(|a, b| Ok(a?.bitor(&b?)))
.map(|bitset| Ok(bitset?.bitand(&present_buf)))
.map(|bitset| {
let bs = bitset?;
Ok(present_buf.map(|b| b.bitand(&bs)).unwrap_or(bs))
})
.unwrap_or_else(|| Ok(BooleanBuffer::new_set(self.len())));

Ok(BoolArray::from(bitset?).into_array())
Expand Down
8 changes: 0 additions & 8 deletions vortex-array/src/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ impl LogicalValidity {
}
}

pub fn to_present_null_buffer(&self) -> VortexResult<NullBuffer> {
match self {
Self::AllValid(l) => Ok(NullBuffer::new_valid(*l)),
Self::AllInvalid(l) => Ok(NullBuffer::new_null(*l)),
Self::Array(a) => Ok(NullBuffer::new(a.clone().into_bool()?.boolean_buffer())),
}
}

pub fn all_valid(&self) -> bool {
matches!(self, Self::AllValid(_))
}
Expand Down

0 comments on commit abb9eaa

Please sign in to comment.