Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-8221

MoreLikeThis.setMaxDocFreqPct can easily int-overflow on larger indexes

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 7.4
    • None
    • None
    • New

    Description

        public void setMaxDocFreqPct(int maxPercentage) {
          this.maxDocFreq = maxPercentage * ir.numDocs() / 100;
        }
      

      The above overflows integer range into negative numbers on even fairly small indexes (for maxPercentage = 75, it happens for just over 28 million documents.

      We should make the computations on long range so that it doesn't overflow and have a more strict argument validation.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            dweiss Dawid Weiss
            dweiss Dawid Weiss
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment