diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-29 12:25:00 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-29 12:34:00 +0200 |
commit | 656e755c584897d298fcf95bea5376f1fb1c13f5 (patch) | |
tree | a7f7423e01ae62a46c33abbcb6f658d8ef16014c /container-search/src/main/java/com/yahoo/prelude/searcher | |
parent | 7ac642eefd2be2b52aa0878ad8d926521fe00a20 (diff) |
Use CompoundName.from in tests and construction of static objects.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/searcher')
4 files changed, 29 insertions, 26 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java index ead6ad53715..9927880c476 100644 --- a/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java @@ -25,10 +25,10 @@ import java.util.Map; @Before(PhaseNames.TRANSFORMED_QUERY) public class FieldCollapsingSearcher extends Searcher { - private static final CompoundName collapse = new CompoundName("collapse"); - private static final CompoundName collapsefield = new CompoundName("collapsefield"); - private static final CompoundName collapsesize = new CompoundName("collapsesize"); - private static final CompoundName collapseSummaryName = new CompoundName("collapse.summary"); + private static final CompoundName collapse = CompoundName.from("collapse"); + private static final CompoundName collapsefield = CompoundName.from("collapsefield"); + private static final CompoundName collapsesize = CompoundName.from("collapsesize"); + private static final CompoundName collapseSummaryName = CompoundName.from("collapse.summary"); /** Maximum number of queries to send next searcher */ private static final int maxQueries = 4; diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java index 409b502f086..7750bd17108 100644 --- a/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java @@ -25,7 +25,7 @@ public class JSONDebugSearcher extends Searcher { public static final String STRUCT_FIELD = "Structured data field (as json): "; public static final String FEATURE_FIELD = "Feature data field (as json): "; - private static final CompoundName PROPERTYNAME = new CompoundName("dumpjson"); + private static final CompoundName PROPERTYNAME = CompoundName.from("dumpjson"); @Override public Result search(Query query, Execution execution) { diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java index 3c61a361cbb..dd2c4a1da7f 100644 --- a/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java @@ -10,7 +10,12 @@ import com.yahoo.search.result.Hit; import com.yahoo.search.result.HitGroup; import com.yahoo.search.searchchain.Execution; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * Groups hits according to document type. @@ -21,9 +26,9 @@ import java.util.*; public class MultipleResultsSearcher extends Searcher { private final static String propertyPrefix = "multipleresultsets."; - private static final CompoundName additionalHitsFactorName=new CompoundName(propertyPrefix + "additionalHitsFactor"); - private static final CompoundName maxTimesRetrieveHeterogeneousHitsName=new CompoundName(propertyPrefix + "maxTimesRetrieveHeterogeneousHits"); - private static final CompoundName numHits=new CompoundName(propertyPrefix + "numHits"); + private static final CompoundName additionalHitsFactorName = CompoundName.from(propertyPrefix + "additionalHitsFactor"); + private static final CompoundName maxTimesRetrieveHeterogeneousHitsName = CompoundName.from(propertyPrefix + "maxTimesRetrieveHeterogeneousHits"); + private static final CompoundName numHits = CompoundName.from(propertyPrefix + "numHits"); @Override public Result search(Query query, Execution e) { @@ -162,9 +167,9 @@ public class MultipleResultsSearcher extends Searcher { // Assumes that field sddocname is available private static class PartitionedResult { - private Map<String, HitGroup> resultSets = new HashMap<>(); + private final Map<String, HitGroup> resultSets = new HashMap<>(); - private List<Hit> otherHits = new ArrayList<>(); + private final List<Hit> otherHits = new ArrayList<>(); PartitionedResult(List<DocumentGroup> documentGroups,Result result) throws ParameterException { for (DocumentGroup group : documentGroups) @@ -174,9 +179,8 @@ public class MultipleResultsSearcher extends Searcher { } void addHits(Result result, boolean addOtherHits) { - Iterator<Hit> i = result.hits().iterator(); - while (i.hasNext()) { - add(i.next(), addOtherHits); + for (Hit hit : result.hits()) { + add(hit, addOtherHits); } } diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java index 0df21df8842..fd4c9e89f3b 100644 --- a/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java @@ -37,12 +37,11 @@ public class PosSearcher extends Searcher { public static final String POSITION_PARSING = "PositionParsing"; - private static final CompoundName posBb = new CompoundName("pos.bb"); - private static final CompoundName posLl = new CompoundName("pos.ll"); - private static final CompoundName posXy = new CompoundName("pos.xy"); - private static final CompoundName posAttributeName = new CompoundName("pos.attribute"); - private static final CompoundName posRadius = new CompoundName("pos.radius"); - private static final CompoundName posUnits = new CompoundName("pos.units"); + private static final CompoundName posBb = CompoundName.from("pos.bb"); + private static final CompoundName posLl = CompoundName.from("pos.ll"); + private static final CompoundName posXy = CompoundName.from("pos.xy"); + private static final CompoundName posAttributeName = CompoundName.from("pos.attribute"); + private static final CompoundName posRadius = CompoundName.from("pos.radius"); // according to wikipedia: // Earth's equatorial radius = 6378137 meter - not used @@ -117,13 +116,13 @@ public class PosSearcher extends Searcher { if (radius == null) { radiusdegrees = 50.0 * km2deg; } else if (radius.endsWith("km")) { - double radiuskm = Double.valueOf(radius.substring(0, radius.length()-2)); + double radiuskm = Double.parseDouble(radius.substring(0, radius.length()-2)); radiusdegrees = radiuskm * km2deg; } else if (radius.endsWith("m")) { - double radiusm = Double.valueOf(radius.substring(0, radius.length()-1)); + double radiusm = Double.parseDouble(radius.substring(0, radius.length()-1)); radiusdegrees = radiusm * km2deg / 1000.0; } else if (radius.endsWith("mi")) { - double radiusmiles = Double.valueOf(radius.substring(0, radius.length()-2)); + double radiusmiles = Double.parseDouble(radius.substring(0, radius.length()-2)); radiusdegrees = radiusmiles * mi2deg; } else { radiusdegrees = Integer.parseInt(radius) * 0.000001; @@ -151,15 +150,15 @@ public class PosSearcher extends Searcher { double radiusdegrees = radiuskm * km2deg; radiusUnits = (int)(radiusdegrees * 1000000); } else if (radius.endsWith("km")) { - double radiuskm = Double.valueOf(radius.substring(0, radius.length()-2)); + double radiuskm = Double.parseDouble(radius.substring(0, radius.length()-2)); double radiusdegrees = radiuskm * km2deg; radiusUnits = (int)(radiusdegrees * 1000000); } else if (radius.endsWith("m")) { - double radiusm = Double.valueOf(radius.substring(0, radius.length()-1)); + double radiusm = Double.parseDouble(radius.substring(0, radius.length()-1)); double radiusdegrees = radiusm * km2deg / 1000.0; radiusUnits = (int)(radiusdegrees * 1000000); } else if (radius.endsWith("mi")) { - double radiusmiles = Double.valueOf(radius.substring(0, radius.length()-2)); + double radiusmiles = Double.parseDouble(radius.substring(0, radius.length()-2)); double radiusdegrees = radiusmiles * mi2deg; radiusUnits = (int)(radiusdegrees * 1000000); } else { |