-
-
Notifications
You must be signed in to change notification settings - Fork 671
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
allow slop in both directions #2020
Conversation
allow slop in both directions so "big wolf"~3 can also match "wolf big" This also fixes #1934, when the docsets were reordered by size and didn't match the terms.
@@ -104,7 +104,8 @@ pub(crate) fn intersection_count(left: &[u32], right: &[u32]) -> usize { | |||
/// resulting array in left. | |||
/// | |||
/// Returns the length of the intersection | |||
fn intersection(left: &mut [u32], right: &[u32]) -> usize { | |||
#[inline] | |||
fn intersection(left: &mut Vec<u32>, right: &[u32]) -> usize { |
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.
Does this need to return count
if left
is truncated anyway so that the information is "returned" via left.len()
?
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.
No, but it's clear for the function caller
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 the motivation for this change? If it is to simplify the code, as @adamreichold noted, the new API is really bad.
I'd rather keep the previous logic. If you want to simplify this part, do this in a separate PR, as we will need to make sure that it does not hurt performance.
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.
It's simpler to use, you get the results in left, instead of left[..returned size]
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.
agreed. But currently the change is halfway, can we remove the returned value?
Also can we check it improves or does not hurt perf on phrase queries?
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.
agreed. But currently the change is halfway, can we remove the returned value?
We need to return the count, in case left is not updated
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.
thx
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 results looks good!
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.
We need to return the count, in case left is not updated
I don't understand.
left.len()
is not always the same as the result of the function?
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.
sorry I thought was about intersection_count_with_slop
returned count is never used for intersection
now, I removed it
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #2020 +/- ##
==========================================
- Coverage 94.42% 94.38% -0.04%
==========================================
Files 319 319
Lines 59216 59003 -213
==========================================
- Hits 55914 55691 -223
- Misses 3302 3312 +10
|
if left_val < right_slop { | ||
left_index += 1; | ||
} else if right_slop <= left_val && left_val <= right_val { | ||
let distance = left_val.abs_diff(right_val); |
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.
neat
allow slop in both directions
so "big wolf"~3 can also match "wolf big"
This also fixes #1934, when the docsets were reordered by size and didn't
match the terms.