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

MoreLikeThis.setMaxDocFreqPct can easily int-overflow on larger indexes

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

        1. LUCENE-8221.patch
          3 kB
          Dawid Weiss

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: