Skip to content

Commit

Permalink
Restore perfoamnce of filter bitmask to bitmap conversion for dense r…
Browse files Browse the repository at this point in the history
…owmasks (#1302)
  • Loading branch information
robert3005 authored Nov 14, 2024
1 parent 8214b78 commit 5ad2cd3
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions vortex-file/src/read/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,24 @@ impl RowMask {

/// Combine the RowMask with bitmask values resulting in new RowMask containing only values true in the bitmask
pub fn and_bitmask(self, bitmask: Array) -> VortexResult<Self> {
// TODO(robert): Avoid densifying sparse values just to get true indices
let sparse_mask =
SparseArray::try_new(self.to_indices_array()?, bitmask, self.len(), false.into())?
.into_array()
.into_bool()?;
Self::from_mask_array(sparse_mask.as_ref(), self.begin(), self.end())
// If we are a dense all true bitmap just take the bitmask array
if self.len() as u64 == self.values.cardinality() {
if bitmask.len() != self.len() {
vortex_bail!(
"Bitmask length {} does not match our length {}",
bitmask.len(),
self.values.cardinality()
);
}
Self::from_mask_array(&bitmask, self.begin, self.end)
} else {
// TODO(robert): Avoid densifying sparse values just to get true indices
let sparse_mask =
SparseArray::try_new(self.to_indices_array()?, bitmask, self.len(), false.into())?
.into_array()
.into_bool()?;
Self::from_mask_array(sparse_mask.as_ref(), self.begin(), self.end())
}
}

pub fn is_empty(&self) -> bool {
Expand Down

0 comments on commit 5ad2cd3

Please sign in to comment.