diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-02-12 20:18:33 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-02-12 20:18:33 +0200 |
commit | a1d2d8c438ac22df82c32ad1400fbdd86d232a45 (patch) | |
tree | 1e1f8aa88c8be3b592a07367cf3534afdda80a99 /config-model/src | |
parent | 55ff951d65ea4e0b2b8b847faaa25057c7f00f1f (diff) |
Argh, none of these were inherited....
Diffstat (limited to 'config-model/src')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java | 28 | ||||
-rw-r--r-- | config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java | 11 |
2 files changed, 28 insertions, 11 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 84504361d1f..c828f6beba3 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -55,7 +55,7 @@ public class RankProfile implements Serializable, Cloneable { private int minHitsPerThread = -1; private int numSearchPartitions = -1; - private double termwiseLimit = 1.0; + private Double termwiseLimit = null; /** The drop limit used to drop hits with rank score less than or equal to this value */ private double rankScoreDropLimit = -Double.MAX_VALUE; @@ -426,13 +426,15 @@ public class RankProfile implements Serializable, Cloneable { } public int getRerankCount() { - if (rerankCount>=0) return rerankCount; - if (getInherited()!=null) return getInherited().getRerankCount(); - return -1; + return (rerankCount < 0 && (getInherited() != null)) + ? getInherited().getRerankCount() + : rerankCount; } public int getNumThreadsPerSearch() { - return numThreadsPerSearch; + return (numThreadsPerSearch < 0 && (getInherited() != null)) + ? getInherited().getNumThreadsPerSearch() + : numThreadsPerSearch; } public void setNumThreadsPerSearch(int numThreads) { @@ -440,7 +442,9 @@ public class RankProfile implements Serializable, Cloneable { } public int getMinHitsPerThread() { - return minHitsPerThread; + return (minHitsPerThread < 0 && (getInherited() != null)) + ? getInherited().getMinHitsPerThread() + : minHitsPerThread; } public void setMinHitsPerThread(int minHits) { @@ -451,9 +455,17 @@ public class RankProfile implements Serializable, Cloneable { this.numSearchPartitions = numSearchPartitions; } - public int getNumSearchPartitions() { return numSearchPartitions; } + public int getNumSearchPartitions() { + return (numSearchPartitions < 0 && (getInherited() != null)) + ? getInherited().getNumSearchPartitions() + : numSearchPartitions; + } - public double getTermwiseLimit() { return termwiseLimit; } + public double getTermwiseLimit() { + return ((termwiseLimit == null) && (getInherited() != null)) + ? getInherited().getTermwiseLimit() + : (termwiseLimit != null) ? termwiseLimit : 1.0; + } public void setTermwiseLimit(double termwiseLimit) { this.termwiseLimit = termwiseLimit; } /** Sets the rerank count. Set to -1 to use inherited */ 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 b2968eb4a85..b1bd5fd8a8d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java @@ -58,7 +58,7 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { } @Test - public void testTermwiseLimitAndSomeMore() throws ParseException { + public void testTermwiseLimitAndSomeMoreIncludingInheritance() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); SearchBuilder builder = new SearchBuilder(rankProfileRegistry); builder.importString( @@ -75,16 +75,21 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { " min-hits-per-thread:70\n" + " num-search-partitions:1200\n" + " }\n" + + " rank-profile child inherits parent { }" + "\n" + "}\n"); builder.build(); Search search = builder.getSearch(); - RankProfile rankProfile = rankProfileRegistry.getRankProfile(search, "parent"); + AttributeFields attributeFields = new AttributeFields(search); + verifyRankProfile(rankProfileRegistry.getRankProfile(search, "parent"), attributeFields); + verifyRankProfile(rankProfileRegistry.getRankProfile(search, "child"), attributeFields); + } + + private void verifyRankProfile(RankProfile rankProfile, AttributeFields attributeFields) { assertEquals(0.78, rankProfile.getTermwiseLimit(), 0.000001); assertEquals(8, rankProfile.getNumThreadsPerSearch()); assertEquals(70, rankProfile.getMinHitsPerThread()); assertEquals(1200, rankProfile.getNumSearchPartitions()); - AttributeFields attributeFields = new AttributeFields(search); RawRankProfile rawRankProfile = new RawRankProfile(rankProfile, attributeFields); assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.termwise_limit").isPresent()); assertEquals("0.78", findProperty(rawRankProfile.configProperties(), "vespa.matching.termwise_limit").get()); |