diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-08-24 13:21:47 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-08-24 13:21:47 +0200 |
commit | a745e61162fba144bba003aabbfbab601456ed73 (patch) | |
tree | 9aee65bc8e2d76c8e87c73ba4c02647716a0c4f0 /config-model | |
parent | 4cfbebbc39f08218596e43fffbea8f9a4cd77538 (diff) |
Cleanup rank profile registry
Diffstat (limited to 'config-model')
24 files changed, 86 insertions, 105 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index aef6c02b7fc..d87c46ef3cb 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -152,7 +152,7 @@ public class RankProfile implements Serializable, Cloneable { return search != null ? search.applicationPackage() : model.applicationPackage(); } - /** Returns the rankinng constants of the owner of this */ + /** Returns the ranking constants of the owner of this */ public RankingConstants rankingConstants() { return search != null ? search.rankingConstants() : model.rankingConstants(); } @@ -182,13 +182,13 @@ public class RankProfile implements Serializable, Cloneable { public RankProfile getInherited() { if (getSearch() == null) return getInheritedFromRegistry(inheritedName); - RankProfile inheritedInThisSearch = rankProfileRegistry.getRankProfile(search, inheritedName); + RankProfile inheritedInThisSearch = rankProfileRegistry.get(search, inheritedName); if (inheritedInThisSearch != null) return inheritedInThisSearch; return getInheritedFromRegistry(inheritedName); } private RankProfile getInheritedFromRegistry(String inheritedName) { - for (RankProfile r : rankProfileRegistry.allRankProfiles()) { + for (RankProfile r : rankProfileRegistry.all()) { if (r.getName().equals(inheritedName)) { return r; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java index 8b1d6381a22..599eef57b2f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; -import com.yahoo.searchdefinition.expressiontransforms.ExpressionTransforms; - import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -16,7 +14,7 @@ import java.util.Set; * Having both of these mappings consolidated here make it easier to remove dependencies on these mappings at * run time, since it is essentially only used when building rank profile config at deployment time. * - * TODO: Rank profiles should be stored under its owning Search instance. + * Global rank profiles are represented by the Search key null. * * @author Ulf Lilleengen */ @@ -30,8 +28,8 @@ public class RankProfileRegistry { public static RankProfileRegistry createRankProfileRegistryWithBuiltinRankProfiles(Search search) { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - rankProfileRegistry.addRankProfile(new DefaultRankProfile(search, rankProfileRegistry)); - rankProfileRegistry.addRankProfile(new UnrankedRankProfile(search, rankProfileRegistry)); + rankProfileRegistry.add(new DefaultRankProfile(search, rankProfileRegistry)); + rankProfileRegistry.add(new UnrankedRankProfile(search, rankProfileRegistry)); return rankProfileRegistry; } @@ -40,16 +38,16 @@ public class RankProfileRegistry { * * @param rankProfile the rank profile to add */ - public void addRankProfile(RankProfile rankProfile) { + public void add(RankProfile rankProfile) { if ( ! rankProfiles.containsKey(rankProfile.getSearch())) { rankProfiles.put(rankProfile.getSearch(), new LinkedHashMap<>()); } - checkForDuplicateRankProfile(rankProfile); + checkForDuplicate(rankProfile); rankProfiles.get(rankProfile.getSearch()).put(rankProfile.getName(), rankProfile); rankProfileToSearch.put(rankProfile, rankProfile.getSearch()); } - private void checkForDuplicateRankProfile(RankProfile rankProfile) { + private void checkForDuplicate(RankProfile rankProfile) { String rankProfileName = rankProfile.getName(); RankProfile existingRangProfileWithSameName = rankProfiles.get(rankProfile.getSearch()).get(rankProfileName); if (existingRangProfileWithSameName == null) return; @@ -63,11 +61,11 @@ public class RankProfileRegistry { /** * Returns a named rank profile, null if the search definition doesn't have one with the given name * - * @param search The {@link Search} that owns the rank profile. - * @param name The name of the rank profile - * @return The RankProfile to return. + * @param search the {@link Search} that owns the rank profile. + * @param name the name of the rank profile + * @return the RankProfile to return. */ - public RankProfile getRankProfile(Search search, String name) { + public RankProfile get(Search search, String name) { return rankProfiles.get(search).get(name); } @@ -75,16 +73,17 @@ public class RankProfileRegistry { * Rank profiles that are collected across clusters. * @return A set of global {@link RankProfile} instances. */ - public Set<RankProfile> allRankProfiles() { + public Set<RankProfile> all() { return rankProfileToSearch.keySet(); } /** - * Rank profiles that are collected for a given search definition - * @param search {@link Search} to get rank profiles for. - * @return A collection of local {@link RankProfile} instances. + * Returns the rank profiles of a given search definition. + * + * @param search {@link Search} to get rank profiles for + * @return a collection of {@link RankProfile} instances */ - public Collection<RankProfile> localRankProfiles(Search search) { + public Collection<RankProfile> rankProfilesOf(Search search) { Map<String, RankProfile> mapping = rankProfiles.get(search); if (mapping == null) { return Collections.emptyList(); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java index 1e978e43d6a..a0bac42d9b9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java @@ -38,13 +38,13 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ ImportedModels importedModels, Search search, AttributeFields attributeFields) { - RawRankProfile defaultProfile = new RawRankProfile(rankProfileRegistry.getRankProfile(search, "default"), + RawRankProfile defaultProfile = new RawRankProfile(rankProfileRegistry.get(search, "default"), queryProfiles, importedModels, attributeFields); rankProfiles.put(defaultProfile.getName(), defaultProfile); - for (RankProfile rank : rankProfileRegistry.localRankProfiles(search)) { + for (RankProfile rank : rankProfileRegistry.rankProfilesOf(search)) { if ("default".equals(rank.getName())) continue; RawRankProfile rawRank = new RawRankProfile(rank, queryProfiles, importedModels, attributeFields); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java index a936045af3a..6b78da2146b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java @@ -21,7 +21,7 @@ public class DiversitySettingsValidator extends Processor { public void process(boolean validate) { if ( ! validate) return; - for (RankProfile rankProfile : rankProfileRegistry.localRankProfiles(search)) { + for (RankProfile rankProfile : rankProfileRegistry.rankProfilesOf(search)) { if (rankProfile.getMatchPhaseSettings() != null && rankProfile.getMatchPhaseSettings().getDiversity() != null) { validate(rankProfile, rankProfile.getMatchPhaseSettings().getDiversity()); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java index 39d35cce694..0c75314ffa2 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java @@ -33,7 +33,7 @@ public class FilterFieldNames extends Processor { } } - for (RankProfile profile : rankProfileRegistry.localRankProfiles(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { Set<String> filterFields = new LinkedHashSet<>(); findFilterFields(search, profile, filterFields); for (Iterator<String> itr = filterFields.iterator(); itr.hasNext(); ) { @@ -45,7 +45,7 @@ public class FilterFieldNames extends Processor { } private void filterField(String f) { - for (RankProfile rp : rankProfileRegistry.localRankProfiles(search)) { + for (RankProfile rp : rankProfileRegistry.rankProfilesOf(search)) { rp.filterFields().add(f); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java index 043eb1f82eb..479384e09ef 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java @@ -23,7 +23,7 @@ public class MatchPhaseSettingsValidator extends Processor { public void process(boolean validate) { if ( ! validate) return; - for (RankProfile rankProfile : rankProfileRegistry.localRankProfiles(search)) { + for (RankProfile rankProfile : rankProfileRegistry.rankProfilesOf(search)) { RankProfile.MatchPhaseSettings settings = rankProfile.getMatchPhaseSettings(); if (settings != null) { validateMatchPhaseSettings(rankProfile, settings); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java index b0fbc6c1998..b938e40d9a2 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java @@ -100,7 +100,7 @@ public abstract class Processor { { List<RankProfile.RankSetting> someRankSettings = new java.util.ArrayList<>(); - for (RankProfile profile : rankProfileRegistry.localRankProfiles(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { for (Iterator j = profile.declaredRankSettingIterator(); j.hasNext(); ) { RankProfile.RankSetting setting = (RankProfile.RankSetting)j.next(); if (setting.getType().equals(type)) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidator.java index f7f314f8444..81455991cc9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidator.java @@ -36,7 +36,7 @@ public class RankingExpressionTypeValidator extends Processor { public void process(boolean validate) { if ( ! validate) return; - for (RankProfile profile : rankProfileRegistry.localRankProfiles(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { try { validate(profile); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedMacroNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedMacroNames.java index b8eb1e1d8cf..adcebed9254 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedMacroNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedMacroNames.java @@ -9,7 +9,6 @@ import com.yahoo.searchdefinition.Search; import com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParserConstants; import com.yahoo.vespa.model.container.search.QueryProfiles; -import java.util.HashSet; import java.util.Set; import java.util.logging.Level; @@ -31,7 +30,7 @@ public class ReservedMacroNames extends Processor { public void process(boolean validate) { if ( ! validate) return; - for (RankProfile rp : rankProfileRegistry.allRankProfiles()) { + for (RankProfile rp : rankProfileRegistry.all()) { for (String macroName : rp.getMacros().keySet()) { if (reservedNames.contains(macroName)) { deployLogger.log(Level.WARNING, "Macro \"" + macroName + "\" " + diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java index 21567edb94b..cc1638347f6 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java @@ -66,7 +66,7 @@ public class RankProfileTypeSettingsProcessor extends Processor { } private void addAttributeTypeToRankProfiles(String attributeName, String attributeType) { - for (RankProfile profile : rankProfileRegistry.allRankProfiles()) { + for (RankProfile profile : rankProfileRegistry.all()) { profile.addAttributeType(attributeName, attributeType); } } @@ -90,7 +90,7 @@ public class RankProfileTypeSettingsProcessor extends Processor { } private void addQueryFeatureTypeToRankProfiles(String queryFeature, String queryFeatureType) { - for (RankProfile profile : rankProfileRegistry.allRankProfiles()) { + for (RankProfile profile : rankProfileRegistry.all()) { profile.addQueryFeatureType(queryFeature, queryFeatureType); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java index edc0462c6ee..e20bc4d96aa 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; -import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.search.query.ranking.Diversity; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -45,7 +44,7 @@ public class DiversityTestCase { "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile.MatchPhaseSettings matchPhase = rankProfileRegistry.getRankProfile(s, "parent").getMatchPhaseSettings(); + RankProfile.MatchPhaseSettings matchPhase = rankProfileRegistry.get(s, "parent").getMatchPhaseSettings(); RankProfile.DiversitySettings diversity = matchPhase.getDiversity(); assertEquals("b", diversity.getAttribute()); assertEquals(74, diversity.getMinGroups()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java index 6999518e706..82ebdbb9939 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java @@ -34,8 +34,8 @@ public class RankProfileRegistryTest { Search search = new Search("foo", null); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search); RankProfile barRankProfile = new RankProfile("bar", search, rankProfileRegistry); - rankProfileRegistry.addRankProfile(barRankProfile); - rankProfileRegistry.addRankProfile(barRankProfile); + rankProfileRegistry.add(barRankProfile); + rankProfileRegistry.add(barRankProfile); } @Test @@ -44,11 +44,11 @@ public class RankProfileRegistryTest { RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search); for (String rankProfileName : RankProfileRegistry.overridableRankProfileNames) { - assertNull(rankProfileRegistry.getRankProfile(search, rankProfileName).getMacros().get("foo")); + assertNull(rankProfileRegistry.get(search, rankProfileName).getMacros().get("foo")); RankProfile rankProfileWithAddedMacro = new RankProfile(rankProfileName, search, rankProfileRegistry); rankProfileWithAddedMacro.addMacro("foo", true); - rankProfileRegistry.addRankProfile(rankProfileWithAddedMacro); - assertNotNull(rankProfileRegistry.getRankProfile(search, rankProfileName).getMacros().get("foo")); + rankProfileRegistry.add(rankProfileWithAddedMacro); + assertNotNull(rankProfileRegistry.get(search, rankProfileName).getMacros().get("foo")); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java index de9df08f5c0..4df3add13c5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java @@ -17,7 +17,6 @@ import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModels; -import com.yahoo.vespa.model.container.search.QueryProfiles; import org.junit.Test; import java.util.Iterator; @@ -46,7 +45,7 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { search.addDocument(document); RankProfile child = new RankProfile("child", search, rankProfileRegistry); child.setInherited("default"); - rankProfileRegistry.addRankProfile(child); + rankProfileRegistry.add(child); Iterator<RankProfile.RankSetting> i = child.rankSettingIterator(); @@ -83,8 +82,8 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { builder.build(); Search search = builder.getSearch(); AttributeFields attributeFields = new AttributeFields(search); - verifyRankProfile(rankProfileRegistry.getRankProfile(search, "parent"), attributeFields); - verifyRankProfile(rankProfileRegistry.getRankProfile(search, "child"), attributeFields); + verifyRankProfile(rankProfileRegistry.get(search, "parent"), attributeFields); + verifyRankProfile(rankProfileRegistry.get(search, "child"), attributeFields); } private void verifyRankProfile(RankProfile rankProfile, AttributeFields attributeFields) { @@ -119,11 +118,11 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { builder.build(); Search search = builder.getSearch(); - assertEquals(4, registry.allRankProfiles().size()); - assertAttributeTypeSettings(registry.getRankProfile(search, "default"), search); - assertAttributeTypeSettings(registry.getRankProfile(search, "unranked"), search); - assertAttributeTypeSettings(registry.getRankProfile(search, "p1"), search); - assertAttributeTypeSettings(registry.getRankProfile(search, "p2"), search); + assertEquals(4, registry.all().size()); + assertAttributeTypeSettings(registry.get(search, "default"), search); + assertAttributeTypeSettings(registry.get(search, "unranked"), search); + assertAttributeTypeSettings(registry.get(search, "p1"), search); + assertAttributeTypeSettings(registry.get(search, "p2"), search); } private static void assertAttributeTypeSettings(RankProfile profile, Search search) { @@ -145,11 +144,11 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { builder.build(true, new BaseDeployLogger()); Search search = builder.getSearch(); - assertEquals(4, registry.allRankProfiles().size()); - assertQueryFeatureTypeSettings(registry.getRankProfile(search, "default"), search); - assertQueryFeatureTypeSettings(registry.getRankProfile(search, "unranked"), search); - assertQueryFeatureTypeSettings(registry.getRankProfile(search, "p1"), search); - assertQueryFeatureTypeSettings(registry.getRankProfile(search, "p2"), search); + assertEquals(4, registry.all().size()); + assertQueryFeatureTypeSettings(registry.get(search, "default"), search); + assertQueryFeatureTypeSettings(registry.get(search, "unranked"), search); + assertQueryFeatureTypeSettings(registry.get(search, "p1"), search); + assertQueryFeatureTypeSettings(registry.get(search, "p2"), search); } private static QueryProfileRegistry setupQueryProfileTypes() { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java index 3a2482b56d0..8df3985fd24 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; -import com.yahoo.collections.Pair; -import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.RawRankProfile; @@ -10,10 +8,6 @@ import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModels; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import static org.junit.Assert.assertEquals; /** @@ -57,7 +51,7 @@ public class RankPropertiesTestCase extends SearchDefinitionTestCase { { // Check declared model - RankProfile parent = rankProfileRegistry.getRankProfile(search, "parent"); + RankProfile parent = rankProfileRegistry.get(search, "parent"); assertEquals("query(a) = 1500", parent.getRankProperties().get(0).toString()); // Check derived model @@ -67,11 +61,11 @@ public class RankPropertiesTestCase extends SearchDefinitionTestCase { { // Check declared model - RankProfile parent = rankProfileRegistry.getRankProfile(search, "child"); + RankProfile parent = rankProfileRegistry.get(search, "child"); assertEquals("query(a) = 2000", parent.getRankProperties().get(0).toString()); // Check derived model - RawRankProfile rawChild = new RawRankProfile(rankProfileRegistry.getRankProfile(search, "child"), + RawRankProfile rawChild = new RawRankProfile(rankProfileRegistry.get(search, "child"), new QueryProfileRegistry(), new ImportedModels(), attributeFields); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java index da546967dc1..a524a26cbef 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java @@ -2,7 +2,6 @@ package com.yahoo.searchdefinition; import com.yahoo.collections.Pair; -import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModels; import com.yahoo.yolean.Exceptions; @@ -11,9 +10,7 @@ import com.yahoo.searchdefinition.derived.RawRankProfile; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import static org.junit.Assert.*; import static org.junit.Assert.assertEquals; @@ -70,14 +67,14 @@ public class RankingExpressionConstantsTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile parent = rankProfileRegistry.getRankProfile(s, "parent").compile(queryProfileRegistry, new ImportedModels()); + RankProfile parent = rankProfileRegistry.get(s, "parent").compile(queryProfileRegistry, new ImportedModels()); assertEquals("0.0", parent.getFirstPhaseRanking().getRoot().toString()); - RankProfile child1 = rankProfileRegistry.getRankProfile(s, "child1").compile(queryProfileRegistry, new ImportedModels()); + RankProfile child1 = rankProfileRegistry.get(s, "child1").compile(queryProfileRegistry, new ImportedModels()); assertEquals("6.5", child1.getFirstPhaseRanking().getRoot().toString()); assertEquals("11.5", child1.getSecondPhaseRanking().getRoot().toString()); - RankProfile child2 = rankProfileRegistry.getRankProfile(s, "child2").compile(queryProfileRegistry, new ImportedModels()); + RankProfile child2 = rankProfileRegistry.get(s, "child2").compile(queryProfileRegistry, new ImportedModels()); assertEquals("16.6", child2.getFirstPhaseRanking().getRoot().toString()); assertEquals("foo: 14.0", child2.getMacros().get("foo").getRankingExpression().toString()); List<Pair<String, String>> rankProperties = new RawRankProfile(child2, @@ -113,7 +110,7 @@ public class RankingExpressionConstantsTestCase extends SearchDefinitionTestCase builder.build(); Search s = builder.getSearch(); try { - rankProfileRegistry.getRankProfile(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); + rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); fail("Should have caused an exception"); } catch (IllegalArgumentException e) { @@ -143,7 +140,7 @@ public class RankingExpressionConstantsTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile profile = rankProfileRegistry.getRankProfile(s, "test"); + RankProfile profile = rankProfileRegistry.get(s, "test"); profile.parseExpressions(); // TODO: Do differently assertEquals("safeLog(popShareSlowDecaySignal,-9.21034037)", profile.getMacros().get("POP_SLOW_SCORE").getRankingExpression().getRoot().toString()); } @@ -172,7 +169,7 @@ public class RankingExpressionConstantsTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile profile = rankProfileRegistry.getRankProfile(s, "test"); + RankProfile profile = rankProfileRegistry.get(s, "test"); profile.parseExpressions(); // TODO: Do differently assertEquals("safeLog(popShareSlowDecaySignal,myValue)", profile.getMacros().get("POP_SLOW_SCORE").getRankingExpression().getRoot().toString()); assertEquals("safeLog(popShareSlowDecaySignal,-9.21034037)", @@ -197,7 +194,7 @@ public class RankingExpressionConstantsTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile profile = rankProfileRegistry.getRankProfile(s, "test"); + RankProfile profile = rankProfileRegistry.get(s, "test"); assertEquals("k1 + (k2 + k3) / 100000000.0", profile.compile(new QueryProfileRegistry(), new ImportedModels()).getMacros().get("rank_default").getRankingExpression().getRoot().toString()); } @@ -223,7 +220,7 @@ public class RankingExpressionConstantsTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile profile = rankProfileRegistry.getRankProfile(s, "test"); + RankProfile profile = rankProfileRegistry.get(s, "test"); assertEquals("0.5 + 50 * (attribute(rating_yelp) - 3)", profile.compile(new QueryProfileRegistry(), new ImportedModels()).getMacros().get("rank_default").getRankingExpression().getRoot().toString()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java index 555aa698c65..e1ddd0c02ca 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java @@ -62,10 +62,10 @@ public class RankingExpressionInliningTestCase extends SearchDefinitionTestCase builder.build(); Search s = builder.getSearch(); - RankProfile parent = rankProfileRegistry.getRankProfile(s, "parent").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile parent = rankProfileRegistry.get(s, "parent").compile(new QueryProfileRegistry(), new ImportedModels()); assertEquals("7.0 * (3 + attribute(a) + attribute(b) * (attribute(a) * 3 + if (7.0 < attribute(a), 1, 2) == 0))", parent.getFirstPhaseRanking().getRoot().toString()); - RankProfile child = rankProfileRegistry.getRankProfile(s, "child").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile child = rankProfileRegistry.get(s, "child").compile(new QueryProfileRegistry(), new ImportedModels()); assertEquals("7.0 * (9 + attribute(a))", child.getFirstPhaseRanking().getRoot().toString()); } @@ -122,14 +122,14 @@ public class RankingExpressionInliningTestCase extends SearchDefinitionTestCase builder.build(); Search s = builder.getSearch(); - RankProfile parent = rankProfileRegistry.getRankProfile(s, "parent").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile parent = rankProfileRegistry.get(s, "parent").compile(new QueryProfileRegistry(), new ImportedModels()); assertEquals("17.0", parent.getFirstPhaseRanking().getRoot().toString()); assertEquals("0.0", parent.getSecondPhaseRanking().getRoot().toString()); assertEquals("10.0", getRankingExpression("foo", parent, s)); assertEquals("17.0", getRankingExpression("firstphase", parent, s)); assertEquals("0.0", getRankingExpression("secondphase", parent, s)); - RankProfile child = rankProfileRegistry.getRankProfile(s, "child").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile child = rankProfileRegistry.get(s, "child").compile(new QueryProfileRegistry(), new ImportedModels()); assertEquals("31.0 + bar + arg(4.0)", child.getFirstPhaseRanking().getRoot().toString()); assertEquals("24.0", child.getSecondPhaseRanking().getRoot().toString()); assertEquals("12.0", getRankingExpression("foo", child, s)); @@ -178,7 +178,7 @@ public class RankingExpressionInliningTestCase extends SearchDefinitionTestCase builder.build(); Search s = builder.getSearch(); - RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); assertEquals("attribute(a) + C + (attribute(b) + 1)", test.getFirstPhaseRanking().getRoot().toString()); assertEquals("attribute(a) + attribute(b)", getRankingExpression("C", test, s)); assertEquals("attribute(b) + 1", getRankingExpression("D", test, s)); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java index 2bd7d3031a5..1ece2355a92 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java @@ -10,12 +10,9 @@ import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.RawRankProfile; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModels; -import org.junit.Ignore; import org.junit.Test; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import static org.junit.Assert.assertEquals; @@ -45,7 +42,7 @@ public class RankingExpressionShadowingTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); List<Pair<String, String>> testRankProperties = new RawRankProfile(test, new QueryProfileRegistry(), new ImportedModels(), @@ -89,7 +86,7 @@ public class RankingExpressionShadowingTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); List<Pair<String, String>> testRankProperties = new RawRankProfile(test, new QueryProfileRegistry(), new ImportedModels(), @@ -139,7 +136,7 @@ public class RankingExpressionShadowingTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); + RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedModels()); List<Pair<String, String>> testRankProperties = new RawRankProfile(test, new QueryProfileRegistry(), new ImportedModels(), @@ -203,7 +200,7 @@ public class RankingExpressionShadowingTestCase extends SearchDefinitionTestCase "}\n"); builder.build(); Search s = builder.getSearch(); - RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(queryProfiles, new ImportedModels()); + RankProfile test = rankProfileRegistry.get(s, "test").compile(queryProfiles, new ImportedModels()); List<Pair<String, String>> testRankProperties = new RawRankProfile(test, queryProfiles, new ImportedModels(), diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java index ace70e69959..8cdfdd51637 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java @@ -131,20 +131,20 @@ public class SearchImporterTestCase extends SearchDefinitionTestCase { assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType()); // Rank Profiles - RankProfile profile=rankProfileRegistry.getRankProfile(search, "default"); + RankProfile profile=rankProfileRegistry.get(search, "default"); assertNotNull(profile); assertNull(profile.getInheritedName()); assertEquals(null,profile.getDeclaredRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE)); assertEquals(RankType.EMPTY, profile.getRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE).getValue()); - profile=rankProfileRegistry.getRankProfile(search, "experimental"); + profile=rankProfileRegistry.get(search, "experimental"); assertNotNull(profile); assertEquals("default",profile.getInheritedName()); assertEquals(RankType.IDENTITY, profile.getDeclaredRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE).getValue()); - profile=rankProfileRegistry.getRankProfile(search, "other"); + profile=rankProfileRegistry.get(search, "other"); assertNotNull(profile); assertEquals("experimental",profile.getInheritedName()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java index dec4b734f27..94d0bf6329a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java @@ -38,7 +38,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { field1.parseIndexingScript("{ index }"); field1.setLiteralBoost(20); RankProfile other=new RankProfile("other", search, rankProfileRegistry); - rankProfileRegistry.addRankProfile(other); + rankProfileRegistry.add(other); other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333)); Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true); @@ -69,7 +69,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { SDField field1= document.addField("a", DataType.STRING); field1.parseIndexingScript("{ index }"); RankProfile other=new RankProfile("other", search, rankProfileRegistry); - rankProfileRegistry.addRankProfile(other); + rankProfileRegistry.add(other); other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333)); search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java index 45cdbfa9c1f..9bbc1347aeb 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java @@ -82,14 +82,14 @@ class RankProfileSearchFixture { } public RankProfile compileRankProfile(String rankProfile, Path applicationDir) { - RankProfile compiled = rankProfileRegistry.getRankProfile(search, rankProfile).compile(queryProfileRegistry, new ImportedModels(applicationDir.toFile())); + RankProfile compiled = rankProfileRegistry.get(search, rankProfile).compile(queryProfileRegistry, new ImportedModels(applicationDir.toFile())); compiledRankProfiles.put(rankProfile, compiled); return compiled; } /** Returns the given uncompiled profile */ public RankProfile rankProfile(String rankProfile) { - return rankProfileRegistry.getRankProfile(search, rankProfile); + return rankProfileRegistry.get(search, rankProfile); } /** Returns the given compiled profile, or null if not compiled yet or not present at all */ diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java index df2bcca63dd..d740884d3e5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java @@ -25,12 +25,12 @@ public class RankPropertyVariablesTestCase extends SearchDefinitionTestCase { new BaseDeployLogger(), rankProfileRegistry, new QueryProfileRegistry()); - assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar1", "foo"); - assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar_2", "bar"); - assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvarOne23", "baz"); - assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar1", "1"); - assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar_4", "4"); - assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$testvarFour23", "234234.234"); + assertRankPropEquals(rankProfileRegistry.get(search, "other").getRankProperties(), "$testvar1", "foo"); + assertRankPropEquals(rankProfileRegistry.get(search, "other").getRankProperties(), "$testvar_2", "bar"); + assertRankPropEquals(rankProfileRegistry.get(search, "other").getRankProperties(), "$testvarOne23", "baz"); + assertRankPropEquals(rankProfileRegistry.get(search, "another").getRankProperties(), "$Testvar1", "1"); + assertRankPropEquals(rankProfileRegistry.get(search, "another").getRankProperties(), "$Testvar_4", "4"); + assertRankPropEquals(rankProfileRegistry.get(search, "another").getRankProperties(), "$testvarFour23", "234234.234"); } private void assertRankPropEquals(List<RankProperty> props, String key, String val) { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidatorTestCase.java index 61baee6da26..d8eb4368b57 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidatorTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeValidatorTestCase.java @@ -3,12 +3,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.SearchBuilder; import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode; import com.yahoo.tensor.TensorType; import com.yahoo.yolean.Exceptions; -import org.junit.Ignore; import org.junit.Test; import java.util.Map; @@ -137,7 +135,7 @@ public class RankingExpressionTypeValidatorTestCase { )); builder.build(); RankProfile profile = - builder.getRankProfileRegistry().getRankProfile(builder.getSearch(), "my_rank_profile"); + builder.getRankProfileRegistry().get(builder.getSearch(), "my_rank_profile"); assertEquals(TensorType.fromSpec("tensor(x[],y[])"), summaryFeatures(profile).get("macro1(a)").type(profile.typeContext(builder.getQueryProfileRegistry()))); assertEquals(TensorType.fromSpec("tensor(z[10])"), @@ -179,7 +177,7 @@ public class RankingExpressionTypeValidatorTestCase { )); builder.build(); RankProfile profile = - builder.getRankProfileRegistry().getRankProfile(builder.getSearch(), "my_rank_profile"); + builder.getRankProfileRegistry().get(builder.getSearch(), "my_rank_profile"); assertEquals(TensorType.fromSpec("tensor(x[],y[])"), summaryFeatures(profile).get("return_a").type(profile.typeContext(builder.getQueryProfileRegistry()))); assertEquals(TensorType.fromSpec("tensor(z[10])"), diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java index 31ceb97ab50..86127a260c5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java @@ -12,7 +12,6 @@ import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModels; import org.junit.Test; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -26,7 +25,7 @@ public class RankingExpressionsTestCase extends SearchDefinitionTestCase { Search search = SearchBuilder.createFromDirectory("src/test/examples/rankingexpressionfunction", rankProfileRegistry, new QueryProfileRegistry()).getSearch(); - final RankProfile macrosRankProfile = rankProfileRegistry.getRankProfile(search, "macros"); + final RankProfile macrosRankProfile = rankProfileRegistry.get(search, "macros"); macrosRankProfile.parseExpressions(); final Map<String, RankProfile.Macro> macros = macrosRankProfile.getMacros(); assertEquals(2, macros.get("titlematch$").getFormalParams().size()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java index 6b287c77a10..76c50821cb9 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java @@ -200,7 +200,7 @@ public class TensorTransformTestCase extends SearchDefinitionTestCase { "}\n"); builder.build(true, new BaseDeployLogger()); Search s = builder.getSearch(); - RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(queryProfiles, new ImportedModels()); + RankProfile test = rankProfileRegistry.get(s, "test").compile(queryProfiles, new ImportedModels()); List<Pair<String, String>> testRankProperties = new RawRankProfile(test, queryProfiles, new ImportedModels(), |