-
Notifications
You must be signed in to change notification settings - Fork 1k
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
base: main
Are you sure you want to change the base?
Simplify logic in ScoreCachingWrappingScorer #14012
Conversation
This is functionally equivalent to the logic that was present, but makes the behavior clearer.
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 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; |
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.
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).
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.
+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.
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.
Nice simplification.
@@ -31,8 +31,7 @@ | |||
*/ | |||
public final class ScoreCachingWrappingScorer extends Scorable { | |||
|
|||
private int lastDoc = -1; | |||
private int curDoc = -1; | |||
private boolean computeScore; |
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.
+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.
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 |
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.
Looks good, @msfroh.. Can you also add a Changes entry?
Description
This is functionally equivalent to the logic that was present, but makes the behavior clearer.