summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2019-08-30 21:43:52 +0200
committerGitHub <noreply@github.com>2019-08-30 21:43:52 +0200
commit4fbe8e1b9f448ada9fbe3a6c5b532440282a3f51 (patch)
treef3308778d85174d9964741225f89f55a1e4a5049 /container-search
parent588652ad5a4b96d23859909894193d02f083cbc3 (diff)
parent3d20fdae88511eade993688926294c3861497bbe (diff)
Merge pull request #10470 from vespa-engine/bratseth/variants-with-multiple-inheritance
Compile all variants also with multiple inheritance
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java7
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java27
2 files changed, 30 insertions, 4 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java
index f75d04a1311..826c9949bcf 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java
@@ -75,10 +75,11 @@ public class QueryProfileCompiler {
variants.addAll(collectVariantsInThis(path, ((BackedOverridableQueryProfile) profile).getBacking(), currentVariant));
Set<DimensionBindingForPath> parentVariants = new HashSet<>();
- for (QueryProfile inheritedProfile : profile.inherited())
+ for (QueryProfile inheritedProfile : profile.inherited()) {
parentVariants = collectVariants(path, inheritedProfile, currentVariant);
- variants.addAll(parentVariants);
- variants.addAll(combined(variants, parentVariants)); // parents and children may have different variant dimensions
+ variants.addAll(parentVariants);
+ variants.addAll(combined(variants, parentVariants)); // parents and children may have different variant dimensions
+ }
return variants;
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
index b14e73d156d..46dbac859a2 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
@@ -72,7 +72,7 @@ public class QueryProfileVariantsTestCase {
QueryProfile parent = new QueryProfile("parent");
parent.setDimensions(new String[] { "parentDim" });
parent.set("property", "defaultValue", null);
- parent.set("property", "variantValue", new String[] {"V2" }, null);
+ parent.set("property", "variantValue", new String[] { "V2" }, null);
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
@@ -82,7 +82,32 @@ public class QueryProfileVariantsTestCase {
CompiledQueryProfile cchild = child.compile(null);
assertEquals("defaultValue", new Query("?query=test", cchild).properties().get("property"));
assertEquals("variantValue", new Query("?parentDim=V2", cchild).properties().get("property"));
+ assertEquals("defaultValue", new Query("?childDim=V1", cchild).properties().get("property"));
assertEquals("variantValue", new Query("?parentDim=V2&childDim=V1", cchild).properties().get("property"));
+ assertEquals("variantValue", new Query("?parentDim=V2&childDim=NO", cchild).properties().get("property"));
+ }
+
+ @Test
+ public void testInheritedVariantsMultipleInheritance() {
+ QueryProfile parent = new QueryProfile("parent");
+ parent.setDimensions(new String[] { "parentDim" });
+ parent.set("property", "defaultValue", null);
+ parent.set("property", "variantValue", new String[] { "V2" }, null);
+
+ QueryProfile otherParent = new QueryProfile("otherParent");
+
+ QueryProfile child = new QueryProfile("child");
+ child.addInherited(parent);
+ child.addInherited(otherParent);
+ child.setDimensions(new String[] { "childDim" });
+ child.set("otherProperty", "otherPropertyValue", new String[] { "V1" }, null);
+
+ CompiledQueryProfile cchild = child.compile(null);
+ assertEquals("defaultValue", new Query("?query=test", cchild).properties().get("property"));
+ assertEquals("variantValue", new Query("?parentDim=V2", cchild).properties().get("property"));
+ assertEquals("defaultValue", new Query("?childDim=V1", cchild).properties().get("property"));
+ assertEquals("variantValue", new Query("?parentDim=V2&childDim=V1", cchild).properties().get("property"));
+ assertEquals("variantValue", new Query("?parentDim=V2&childDim=NO", cchild).properties().get("property"));
}
@Test