apache / apache/lucene

Wasted work in FuzzySet.getNearestSetSize [LUCENE-5083]

Open
#6,147 0 comments 0 reactions 0 assignees View on GitHub
affects-version:4.3.1 legacy-jira-label:patch legacy-jira-label:performance legacy-jira-priority:Minor module:core/codecs type:bug
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.