-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Fix usage of zim::Searcher::getResults() in libkiwix #597
Conversation
Codecov Report
@@ Coverage Diff @@
## master #597 +/- ##
==========================================
- Coverage 64.79% 64.78% -0.01%
==========================================
Files 53 53
Lines 3730 3729 -1
Branches 1856 1856
==========================================
- Hits 2417 2416 -1
Misses 1311 1311
Partials 2 2
Continue to review full report at Codecov.
|
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.
This PR is a "big" and tricky API change.
And it also change the behavior in a way that either it was buggy before or it is buggy now.
This PR change the function arguments from "two" unsigned int (start, end) to "two" other unsigned int (start, number).
So ABI is keep but the API is totally changed. It means that if we forget one call, we will not detect it at compilation and we will introduce a bug difficult to see.
On top of that, we were using getResults
passing the start/end couple.
Now we are passing start/number.
But end=start+number. If start is 0, it doesn't change anything. But if we are getting result in the middle of the search, it is broken.
This change follow the semantic change of openzim/libzim#597. But it is only a semantic change. Nothing is really changed on libzim side. So we should not change things here.
So there is something wrong somewhere. I've the feeling that previous code was wrong as xapian't get_mset
takes maxitem and not end (https://xapian.org/docs/apidoc/html/classXapian_1_1Enquire.html#a1f2e35f79bc731bebfbdaceda17b9892).
It would be nice to have a unit test showing that :
- Either previous code is buggy, then we add a new (failing) test in a commit and fix it in a following commit(s).
- Either this PR is buggy, then we add a new (passing) test in a commit. This commit make the test failing, and we add a new fixup! commit fixing this.
@mgautierfr Showing that the previous code is buggy is easy on libzim side. But on libkiwix side, our |
It seems that the sentence just before the question is the answer to the question :) |
7d67569
to
796d3d8
Compare
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.
Two small change that should be easy to fix.
796d3d8
to
c88dfa2
Compare
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.
Just a small change to be pedantic.
Else we are good.
0617452
to
9cff130
Compare
With this, we eventually want to see the usage of getResults giving a FAILING TEST. This happens because the second argument to getResults is NOT `end` of the range, but `maxResultCount` to retrieve. This will be fixed in the next commit.
The correct usage does not require the user to calculate an `end` using the `pageLength`. We can directly use getResults(start, pageLength)
9cff130
to
9addd82
Compare
Fixes #595
The correct usage does not require the user to calculate an
end
using thepageLength
. We can directly usegetResults(start, pageLength)