diff options
author | Jon Bratseth <bratseth@oath.com> | 2020-06-18 09:10:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 09:10:48 +0200 |
commit | c95cd618e0903ce0e5101ecb3593821bb399a9f9 (patch) | |
tree | 667aadb9fc67ab9d8f220ef298ccc82186c13ac2 /container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java | |
parent | b0bc165e64dbcbb9e8e357f92f46f8bf1c84dbb8 (diff) | |
parent | ed30906d441364b95b99f52355d218a085246fa6 (diff) |
Merge pull request #13619 from vespa-engine/bratseth/spare-capacity-maintainer
Bratseth/spare capacity maintainer
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java b/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java index 97c68ee3da8..2c017410109 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java @@ -12,8 +12,7 @@ import com.google.common.collect.ImmutableList; import com.yahoo.compress.IntegerCompressor; /** - * A set words with differing exactness scores to be used for literal boost - * ranking. + * A set of words with differing exactness scores to be used for literal boost ranking. * * @author Steinar Knutsen */ @@ -145,17 +144,14 @@ public class WordAlternativesItem extends TermItem { } /** - * Return an immutable snapshot of the contained terms. This list will not - * reflect later changes to the item. + * Return an immutable snapshot of the contained terms. This list will not reflect later changes to the item. * - * @return an immutable list of word alternatives and their respective - * scores + * @return an immutable list of word alternatives and their respective scores */ public List<Alternative> getAlternatives() { return alternatives; } - @Override public void encodeThis(ByteBuffer target) { super.encodeThis(target); @@ -172,17 +168,14 @@ public class WordAlternativesItem extends TermItem { * equal or higher exactness score. If the term string is present with a * lower exactness score, the new, higher score will take precedence. * - * @param term - * one of several string interpretations of the input word - * @param exactness - * how close the term string matches what the user input + * @param term one of several string interpretations of the input word + * @param exactness how close the term string matches what the user input */ public void addTerm(String term, double exactness) { // do note, Item is Cloneable, and overwriting the reference is what // saves us from overriding the method - if (alternatives.stream().anyMatch((a) -> a.word.equals(term) && a.exactness >= exactness )) { - return; - } + if (alternatives.stream().anyMatch((a) -> a.word.equals(term) && a.exactness >= exactness )) return; + List<Alternative> newTerms = new ArrayList<>(alternatives.size() + 1); newTerms.addAll(alternatives); newTerms.add(new Alternative(term, exactness)); |