Skip to content
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

Simplify logic in ScoreCachingWrappingScorer #14012

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

msfroh
Copy link
Contributor

@msfroh msfroh commented Nov 22, 2024

Description

This is functionally equivalent to the logic that was present, but makes the behavior clearer.

This is functionally equivalent to the logic that was present, but
makes the behavior clearer.
Copy link
Contributor

@vigyasharma vigyasharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change. It's the first time I read this class, and this PR did make it easier for me. Any reason this is still in draft?

@@ -31,8 +31,7 @@
*/
public final class ScoreCachingWrappingScorer extends Scorable {

private int lastDoc = -1;
private int curDoc = -1;
private boolean computeScore;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: how about renaming this to something that tells whether the score is cached already e.g. scoreCached ?And the flag gets unset whenever we collect a new doc (we would reverse the boolean meaning with this name).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 I had a similar reaction when reading this PR. It's easier for me to reason about when the cached score should be invalidated than when the score should be computed.

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice simplification.

@@ -31,8 +31,7 @@
*/
public final class ScoreCachingWrappingScorer extends Scorable {

private int lastDoc = -1;
private int curDoc = -1;
private boolean computeScore;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 I had a similar reaction when reading this PR. It's easier for me to reason about when the cached score should be invalidated than when the score should be computed.

Keep track current state instead of future plans.
@msfroh msfroh marked this pull request as ready for review November 25, 2024 20:06
@msfroh
Copy link
Contributor Author

msfroh commented Nov 25, 2024

Thanks folks! I made the suggested change and took this PR out of draft.

I think this one makes more sense than my previous one over at #13987

Copy link
Contributor

@vigyasharma vigyasharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, @msfroh.. Can you also add a Changes entry?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants