-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set bloom filter on byte array #3284
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipped null slots now.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this if statement for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could test all the row groups in aggregate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could get a test of nulls and empty strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one test for that.
parquet/src/data_type.rs
Outdated
@@ -448,6 +448,12 @@ impl AsBytes for [u8] { | |||
} | |||
} | |||
|
|||
impl AsBytes for &[u8] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is redundant given the implementation above? Just add &
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it.
@@ -543,7 +549,7 @@ impl ColumnValueEncoder for ByteArrayEncoder { | |||
fn encode<T>(values: T, indices: &[usize], encoder: &mut ByteArrayEncoder) | |||
where | |||
T: ArrayAccessor + Copy, | |||
T::Item: Copy + Ord + AsRef<[u8]>, | |||
T::Item: Copy + Ord + AsRef<[u8]> + AsBytes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.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?