diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-04-28 15:49:57 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-04-28 15:49:57 +0200 |
commit | 2ee3e1d2e9fdda8d10a91e616e3a4f8d758d7dbe (patch) | |
tree | c20f09ad439cb4f2854a27b2a77dbd250c6b3b4d /container-search/src/test/java/com/yahoo/search/query/profile | |
parent | 357de578bc8d79c71ddb6bbbcf37d11d46902020 (diff) |
Use owner's dimensions in BackedOverridableQueryProfile
Use owner's dimensions rather than the backed's in
BackedObverridableQueryProfile. This matters when a profile
references a profile with different but overlapping dimensions
and both the owner and referred profile assigns values for
the same paths, within their respective dimension spaces.
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/query/profile')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java | 31 |
1 files changed, 31 insertions, 0 deletions
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 89217bb7f0c..a592d40d2e9 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 @@ -10,6 +10,7 @@ import com.yahoo.search.query.profile.BackedOverridableQueryProfile; import com.yahoo.search.query.profile.QueryProfile; import com.yahoo.search.query.profile.QueryProfileProperties; import com.yahoo.search.query.profile.QueryProfileRegistry; +import com.yahoo.search.query.profile.QueryProfileVariant; import com.yahoo.search.query.profile.compiled.CompiledQueryProfile; import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry; import com.yahoo.search.query.profile.compiled.ValueWithSource; @@ -103,6 +104,36 @@ public class QueryProfileVariantsTestCase { cRegistry.getComponent("test").get("a.b", Map.of("d1", "d1v"))); } + /** + * Tests referencing a variant which modifies the dimension set, + * and also setting a value within that variants subspace. + */ + @Test + public void testVariantReference() { + QueryProfileRegistry registry = new QueryProfileRegistry(); + + QueryProfile parent = new QueryProfile("parent"); + parent.set("b", 48, registry); + registry.register(parent); + + QueryProfile referenced = new QueryProfile("referenced"); + referenced.addInherited(parent); + referenced.setDimensions(new String[] {"d2", "d3"}); + registry.register(referenced); + + QueryProfile base = new QueryProfile("base"); + base.setDimensions(new String[]{"d1", "d2", "d3"}); + base.set("a", referenced, new String[] {null, null, "d3-val"}, registry); + assertEquals("Variant dimensions are not overridden by the referenced dimensions", + "[d1, d2, d3]", + ((QueryProfile)base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString()); + base.set("a.b", 1, new String[] {null, null, "d3-val"}, registry); + QueryProfileVariant aVariants = base.getVariants().getVariants().get(0); + assertEquals("Variant dimensions are not overridden by the referenced dimensions", + "[d1, d2, d3]", + ((QueryProfile)base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString()); + } + @Test public void testReference() { QueryProfileRegistry registry = new QueryProfileRegistry(); |