Skip to content

Commit 5ad2cd3

Browse files
authored
Restore perfoamnce of filter bitmask to bitmap conversion for dense rowmasks (#1302)
1 parent 8214b78 commit 5ad2cd3

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

vortex-file/src/read/mask.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,24 @@ impl RowMask {
121121

122122
/// Combine the RowMask with bitmask values resulting in new RowMask containing only values true in the bitmask
123123
pub fn and_bitmask(self, bitmask: Array) -> VortexResult<Self> {
124-
// TODO(robert): Avoid densifying sparse values just to get true indices
125-
let sparse_mask =
126-
SparseArray::try_new(self.to_indices_array()?, bitmask, self.len(), false.into())?
127-
.into_array()
128-
.into_bool()?;
129-
Self::from_mask_array(sparse_mask.as_ref(), self.begin(), self.end())
124+
// If we are a dense all true bitmap just take the bitmask array
125+
if self.len() as u64 == self.values.cardinality() {
126+
if bitmask.len() != self.len() {
127+
vortex_bail!(
128+
"Bitmask length {} does not match our length {}",
129+
bitmask.len(),
130+
self.values.cardinality()
131+
);
132+
}
133+
Self::from_mask_array(&bitmask, self.begin, self.end)
134+
} else {
135+
// TODO(robert): Avoid densifying sparse values just to get true indices
136+
let sparse_mask =
137+
SparseArray::try_new(self.to_indices_array()?, bitmask, self.len(), false.into())?
138+
.into_array()
139+
.into_bool()?;
140+
Self::from_mask_array(sparse_mask.as_ref(), self.begin(), self.end())
141+
}
130142
}
131143

132144
pub fn is_empty(&self) -> bool {

0 commit comments

Comments
 (0)