diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-08-20 08:56:52 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-08-20 08:56:52 +0200 |
commit | 03e88f27bc2278fb711a8c4a8a85763b23067348 (patch) | |
tree | 3a325a5dc2f44ce7186ec202ea6b0fdc03b306ee /config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java | |
parent | e11152b73bb9f4a8020034a6bca63e82124f7b26 (diff) |
Revert "Merge pull request #6619 from vespa-engine/revert-6611-revert-6596-revert-6584-bratseth/generate-rank-profiles-for-all-models-part-2"
This reverts commit 0437e8cc1d550fb8c6d24ffe4da813067c542f62, reversing
changes made to 1715b8393827c159f8709033075066b29932f852.
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java')
-rw-r--r-- | config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java | 28 |
1 files changed, 22 insertions, 6 deletions
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 0ce6129ef7f..ab689b88993 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 @@ -10,7 +10,9 @@ import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.SearchBuilder; import com.yahoo.searchdefinition.parser.ParseException; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static org.junit.Assert.assertEquals; @@ -25,6 +27,7 @@ class RankProfileSearchFixture { private RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); private final QueryProfileRegistry queryProfileRegistry; private Search search; + private Map<String, RankProfile> compiledRankProfiles = new HashMap<>(); RankProfileSearchFixture(String rankProfiles) throws ParseException { this(MockApplicationPackage.createEmpty(), new QueryProfileRegistry(), rankProfiles); @@ -54,25 +57,38 @@ class RankProfileSearchFixture { } public void assertFirstPhaseExpression(String expExpression, String rankProfile) { - assertEquals(expExpression, rankProfile(rankProfile).getFirstPhaseRanking().getRoot().toString()); + assertEquals(expExpression, compiledRankProfile(rankProfile).getFirstPhaseRanking().getRoot().toString()); } public void assertSecondPhaseExpression(String expExpression, String rankProfile) { - assertEquals(expExpression, rankProfile(rankProfile).getSecondPhaseRanking().getRoot().toString()); + assertEquals(expExpression, compiledRankProfile(rankProfile).getSecondPhaseRanking().getRoot().toString()); } public void assertRankProperty(String expValue, String name, String rankProfile) { - List<RankProfile.RankProperty> rankPropertyList = rankProfile(rankProfile).getRankPropertyMap().get(name); + List<RankProfile.RankProperty> rankPropertyList = compiledRankProfile(rankProfile).getRankPropertyMap().get(name); assertEquals(1, rankPropertyList.size()); assertEquals(expValue, rankPropertyList.get(0).getValue()); } - public void assertMacro(String expExpression, String macroName, String rankProfile) { - assertEquals(expExpression, rankProfile(rankProfile).getMacros().get(macroName).getRankingExpression().getRoot().toString()); + public void assertMacro(String expexctedExpression, String macroName, String rankProfile) { + assertEquals(expexctedExpression, + compiledRankProfile(rankProfile).getMacros().get(macroName).getRankingExpression().getRoot().toString()); } + public RankProfile compileRankProfile(String rankProfile) { + RankProfile compiled = rankProfileRegistry.getRankProfile(search, rankProfile).compile(queryProfileRegistry); + compiledRankProfiles.put(rankProfile, compiled); + return compiled; + } + + /** Returns the given uncompiled profile */ public RankProfile rankProfile(String rankProfile) { - return rankProfileRegistry.getRankProfile(search, rankProfile).compile(queryProfileRegistry); + return rankProfileRegistry.getRankProfile(search, rankProfile); + } + + /** Returns the given compiled profile, or null if not compiled yet or not present at all */ + public RankProfile compiledRankProfile(String rankProfile) { + return compiledRankProfiles.get(rankProfile); } public Search search() { return search; } |