Implement Bitmap Filter for UInt8 (Stack-based) · apache/datafusion@5351b95 · GitHub
Skip to content

Commit 5351b95

Browse files
Implement Bitmap Filter for UInt8 (Stack-based)
Replaces HashSet<u8> with a 32-byte stack-allocated bitmap. Provides O(1) membership testing via bit-shifting, significantly reducing memory overhead and improving cache locality. Triggers for UInt8 arrays.
1 parent a84579d commit 5351b95

3 files changed

Lines changed: 149 additions & 24 deletions

File tree

datafusion/physical-expr/src/expressions/in_list/primitive_filter.rs

Lines changed: 131 additions & 23 deletions

datafusion/physical-expr/src/expressions/in_list/static_filter.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,20 @@ pub(super) trait StaticFilter {
3535
/// implementation unwraps the dictionary and operates on its values.
3636
fn contains(&self, v: &dyn Array, negated: bool) -> Result<BooleanArray>;
3737
}
38+
39+
/// Evaluate dictionary-encoded needles by applying a filter to dictionary
40+
/// values and remapping the result through the keys.
41+
macro_rules! handle_dictionary {
42+
($self:ident, $v:ident, $negated:ident) => {
43+
arrow::array::downcast_dictionary_array! {
44+
$v => {
45+
let values_contains = $self.contains($v.values().as_ref(), $negated)?;
46+
let result = arrow::compute::take(&values_contains, $v.keys(), None)?;
47+
return Ok(arrow::array::downcast_array(result.as_ref()))
48+
}
49+
_ => {}
50+
}
51+
};
52+
}
53+
54+
pub(super) use handle_dictionary;

datafusion/physical-expr/src/expressions/in_list/strategy.rs

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)