You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/05/30 13:47:16 UTC

[GitHub] [lucene] mocobeta opened a new pull request, #931: LUCENE-10597: move globalMaxScore to MaxScoreCache

mocobeta opened a new pull request, #931:
URL: https://github.com/apache/lucene/pull/931

   ### Description (or a Jira issue link if you have one)
   See https://issues.apache.org/jira/browse/LUCENE-10597


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] mocobeta commented on pull request #931: LUCENE-10597: move globalMaxScore to MaxScoreCache

Posted by GitBox <gi...@apache.org>.
mocobeta commented on PR #931:
URL: https://github.com/apache/lucene/pull/931#issuecomment-1143401670

   Thanks @jpountz for your review! I'll merge this in shortly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] mocobeta commented on a diff in pull request #931: LUCENE-10597: move globalMaxScore to MaxScoreCache

Posted by GitBox <gi...@apache.org>.
mocobeta commented on code in PR #931:
URL: https://github.com/apache/lucene/pull/931#discussion_r884855095


##########
lucene/core/src/java/org/apache/lucene/search/MaxScoreCache.java:
##########
@@ -80,6 +82,9 @@ int getLevel(int upTo) throws IOException {
 
   /** Return the maximum score for the given {@code level}. */
   float getMaxScoreForLevel(int level) throws IOException {
+    if (level < 0) {

Review Comment:
   The original expression was `level == -1`. "smaller than zero" might be better here since there is an assumption that `level` is greater or equal to zero, I have no strong opinion on it though. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] jpountz commented on a diff in pull request #931: LUCENE-10597: move globalMaxScore to MaxScoreCache

Posted by GitBox <gi...@apache.org>.
jpountz commented on code in PR #931:
URL: https://github.com/apache/lucene/pull/931#discussion_r886555453


##########
lucene/core/src/java/org/apache/lucene/search/MaxScoreCache.java:
##########
@@ -78,8 +85,15 @@ int getLevel(int upTo) throws IOException {
     return -1;
   }
 
+  float getMaxScoreForLevelZero() throws IOException {
+    return getMaxScoreForLevel(0);
+  }
+
   /** Return the maximum score for the given {@code level}. */
-  float getMaxScoreForLevel(int level) throws IOException {
+  private float getMaxScoreForLevel(int level) throws IOException {
+    if (level == -1) {
+      return globalMaxScore;
+    }

Review Comment:
   Nit: I think it'd be cleaner to have this `if` statement in `getMaxScore` instead since -1 is not a proper level, it is a way to mean "I don't have a level that provides information for scores up to this doc ID".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] mocobeta commented on a diff in pull request #931: LUCENE-10597: move globalMaxScore to MaxScoreCache

Posted by GitBox <gi...@apache.org>.
mocobeta commented on code in PR #931:
URL: https://github.com/apache/lucene/pull/931#discussion_r886554085


##########
lucene/core/src/java/org/apache/lucene/search/MaxScoreCache.java:
##########
@@ -78,8 +85,15 @@ int getLevel(int upTo) throws IOException {
     return -1;
   }
 
+  float getMaxScoreForLevelZero() throws IOException {
+    return getMaxScoreForLevel(0);
+  }
+
   /** Return the maximum score for the given {@code level}. */
-  float getMaxScoreForLevel(int level) throws IOException {
+  private float getMaxScoreForLevel(int level) throws IOException {

Review Comment:
   As a by-product I found this can be made private by introducing no-arg `getMaxScoreForLevelZero()` but have no strong opinion and can be reverted.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] mocobeta commented on a diff in pull request #931: LUCENE-10597: move globalMaxScore to MaxScoreCache

Posted by GitBox <gi...@apache.org>.
mocobeta commented on code in PR #931:
URL: https://github.com/apache/lucene/pull/931#discussion_r886621261


##########
lucene/core/src/java/org/apache/lucene/search/MaxScoreCache.java:
##########
@@ -78,8 +85,15 @@ int getLevel(int upTo) throws IOException {
     return -1;
   }
 
+  float getMaxScoreForLevelZero() throws IOException {
+    return getMaxScoreForLevel(0);
+  }
+
   /** Return the maximum score for the given {@code level}. */
-  float getMaxScoreForLevel(int level) throws IOException {
+  private float getMaxScoreForLevel(int level) throws IOException {
+    if (level == -1) {
+      return globalMaxScore;
+    }

Review Comment:
   It makes sense to me. I also added an assertion to just ensure the `level` parameter is not negative - if it happens it should be a bug but Java doesn't have unsigned int type - let me know if it isn't good.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] mocobeta merged pull request #931: LUCENE-10597: move globalMaxScore to MaxScoreCache

Posted by GitBox <gi...@apache.org>.
mocobeta merged PR #931:
URL: https://github.com/apache/lucene/pull/931


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org