Set bloom filter on byte array#3284
Conversation
tustvold
left a comment
There was a problem hiding this comment.
Thank you for this, that was fast 🎉
I think this has an issue with its handling of nulls, but otherwise just some minor nits 👍
| // encode the values into bloom filter if enabled | ||
| if let Some(bloom_filter) = &mut encoder.bloom_filter { | ||
| for idx in 0..values.len() { | ||
| bloom_filter.insert(&values.value(idx)); |
There was a problem hiding this comment.
I think this needs to take into account nulls? Otherwise it will add whatever happens to be in the null slot, most likely an empty string, into the bloom filter?
| if let Some(sbbf) = | ||
| row_group_reader.get_column_bloom_filter(column_index) | ||
| { | ||
| if row_group.num_rows() >= positive_values.len() as i64 { |
There was a problem hiding this comment.
What is this if statement for?
There was a problem hiding this comment.
The function creating the parquet file is configured with various row group size. If the row group is smaller than positive values, not all these values will be in the bloom filter. Then we may not be able to find all values from it (the following assert! will fail).
There was a problem hiding this comment.
Perhaps we could test all the row groups in aggregate?
There was a problem hiding this comment.
I changed it to collect all bloom filters and test against values together.
| } | ||
|
|
||
| #[test] | ||
| fn binary_column_bloom_filter() { |
There was a problem hiding this comment.
Perhaps we could get a test of nulls and empty strings?
parquet/src/data_type.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl AsBytes for &[u8] { |
There was a problem hiding this comment.
I think this is redundant given the implementation above? Just add &
| where | ||
| T: ArrayAccessor + Copy, | ||
| T::Item: Copy + Ord + AsRef<[u8]>, | ||
| T::Item: Copy + Ord + AsRef<[u8]> + AsBytes, |
There was a problem hiding this comment.
I wonder if just adding .as_ref() to the call site would be sufficient instead of adding an additional trait bound? Not sure though. It isn't a major thing, just a very minor nit
There was a problem hiding this comment.
.as_ref() is okay, just requires one trait bound (?Sized) to insert.
|
I took the liberty of fixing clippy for this |
|
Thank you @tustvold |
Which issue does this PR close?
Closes #3275.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?