diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-11 19:30:28 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-11 19:30:28 +0200 |
commit | 041b23876425c58d97e6608c81f4c1d497746a29 (patch) | |
tree | ac3ab374b6562b54380dbff338735d02fb01d2cc /container-search/src/main | |
parent | aa474407e02024a1a5aee459a5f9083f9feb66f1 (diff) |
Use Set that allows null elements
Diffstat (limited to 'container-search/src/main')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/result/HitGroup.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/result/HitGroup.java b/container-search/src/main/java/com/yahoo/search/result/HitGroup.java index ce403861014..be31b91a304 100644 --- a/container-search/src/main/java/com/yahoo/search/result/HitGroup.java +++ b/container-search/src/main/java/com/yahoo/search/result/HitGroup.java @@ -718,7 +718,8 @@ public class HitGroup extends Hit implements DataList<Hit>, Cloneable, Iterable< if (hitFilled.isEmpty()) { filled = null; } else if (hitFilled.size() == 1) { - filled = Set.of(hitFilled.iterator().next()); + //TODO Avoid needing set that allows null .... + filled = Collections.singleton(hitFilled.iterator().next()); } else { filled = new HashSet<>(hitFilled); } @@ -799,8 +800,9 @@ public class HitGroup extends Hit implements DataList<Hit>, Cloneable, Iterable< analyzeHit(hit); Set<String> hitFilled = hit.getFilled(); if (hitFilled != null) { + //TODO Avoid needing set that allows null .... filled = (hitFilled.size() == 1) - ? Set.of(hitFilled.iterator().next()) + ? Collections.singleton(hitFilled.iterator().next()) : hitFilled.isEmpty() ? null : new HashSet<>(hitFilled); setFilledInternal(filled); } @@ -931,9 +933,9 @@ public class HitGroup extends Hit implements DataList<Hit>, Cloneable, Iterable< private Set<String> getFilledSingle(String summaryName, Set<String> summaryNames, Iterator<Hit> iterator) { while (true) { if (summaryNames == null) { - return Set.of(summaryName); + return Collections.singleton(summaryName); } else if (!summaryNames.contains(summaryName)) { - return Set.of(); + return Collections.emptySet(); } summaryNames = getSummaryNamesNextFilledHit(iterator); } |