Wasted work in FuzzySet.getNearestSetSize [LUCENE-5083]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
The problem appears in version 4.3.1 and in revision 1498027. I
attached a two-line patch that fixes it.
In method "FuzzySet.getNearestSetSize", the loop over
"usableBitSetSizes" keeps overriding "result" with
"usableBitSetSizes[i]". Therefore, only the last written value is
visible out of the loop and all the other writes and iterations are
not necessary. The patch iterates from the end of "usableBitSetSizes"
and breaks the first time when "result" is set.
---
Migrated from [LUCENE-5083](https://issues.apache.org/jira/browse/LUCENE-5083) by Adrian Nistor
Environment:
```
any
```
Attachments: [patch.diff](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-5083/patch.diff)
Contributor guide
Research direction
Start by locating FuzzySet.getNearestSetSize and inspect its loop over usableBitSetSizes, then review the attached patch.diff. Done means the redundant result assignments and iterations are avoided while preserving the method's existing result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100