diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-08-30 12:30:36 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-08-30 12:30:36 +0200 |
commit | 3d20fdae88511eade993688926294c3861497bbe (patch) | |
tree | 17d9f8b8bf1d91d7e67f5d65c806b6a0f54e48df /container-search | |
parent | 91339a737e354062c97ce8081d8a7f939a9259e4 (diff) |
Compile all variants also with multiple inheritance
Diffstat (limited to 'container-search')
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 |