tang-hi commented on code in PR #970:
URL: https://github.com/apache/lucene/pull/970#discussion_r903515469


##########
lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggesterBuilder.java:
##########
@@ -124,11 +124,15 @@ public boolean store(DataOutput output) throws 
IOException {
    * <p>TODO: is there a better way to make the fst built to be more 
TopNSearcher friendly?
    */
   private static int maxNumArcsForDedupByte(int currentNumDedupBytes) {
+    // when currentNumDedupBytes larger than 12,the result is definitely 
larger than 255;

Review Comment:
   @dweiss thanks for comment.
   Although it's more readable, but if currentNumDedupBytes is big enough, 
maxArcs  still overflow.(may be it will never happen, i don't know)
   How about <br>
   ```
   long maxArcs = 2 * (long) currentNumDedupBytes +1;
   if (maxArcs >= 255) {
       return 255;
   }
   if (currentNumDedupBytes > 5) {
     maxArcs *= currentNumDedupBytes;
   }
   return (int) Math.min(maxArcs, 255);
   ```
   I think it's more readable and will never overflow



-- 
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-unsubscr...@lucene.apache.org

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


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

Reply via email to