mirror of https://github.com/apache/lucene.git
hunspell GeneratingSuggester: ensure there are never more than 100 roots to process (#13154)
hunspell GeneratingSuggester: ensure there are never more than 100 roots to process
This commit is contained in:
parent
47792dfcd3
commit
193cc62c73
|
@ -221,6 +221,8 @@ Bug Fixes
|
|||
|
||||
* GITHUB#13145: Detect MemorySegmentIndexInput correctly in NRTSuggester. (Uwe Schindler)
|
||||
|
||||
* GITHUB#13154: Hunspell GeneratingSuggester: ensure there are never more than 100 roots to process (Peter Gromov)
|
||||
|
||||
Other
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -88,8 +88,7 @@ class GeneratingSuggester {
|
|||
CharsRef rootChars = entry.root();
|
||||
sc += commonPrefix(word, rootChars) - longerWorsePenalty(word.length(), rootChars.length);
|
||||
|
||||
boolean overflow = roots.size() == MAX_ROOTS;
|
||||
if (overflow && isWorseThan(sc, rootChars, roots.peek())) {
|
||||
if (roots.size() == MAX_ROOTS && isWorseThan(sc, rootChars, roots.peek())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,7 +99,7 @@ class GeneratingSuggester {
|
|||
for (int i = 0; i < forms.length; i++) {
|
||||
if (isSuggestible.test(forms.ints[forms.offset + i])) {
|
||||
roots.add(new Weighted<>(new Root<>(root, forms.ints[forms.offset + i]), sc));
|
||||
if (overflow) {
|
||||
if (roots.size() == MAX_ROOTS) {
|
||||
roots.poll();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue