use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantsAreResolvedBeforeInheritanceSimplified.
public void testVariantsAreResolvedBeforeInheritanceSimplified() {
QueryProfile parent = new QueryProfile("parent");
parent.setDimensions(new String[] { "x", "y" });
parent.set("a", "p.a.x1.y2", new String[] { "x1", "y2" }, null);
QueryProfile child = new QueryProfile("child");
child.setDimensions(new String[] { "x", "y" });
child.addInherited(parent);
child.set("a", "c.a.default", (QueryProfileRegistry) null);
assertEquals("c.a.default", child.compile(null).get("a", toMap("x=x1", "y=y2")));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantInheritanceSimplified.
public void testVariantInheritanceSimplified() {
QueryProfile test = new QueryProfile("test");
test.setDimensions(new String[] { "x", "y" });
QueryProfile x1y2Parent = new QueryProfile("x1y2Parent");
x1y2Parent.set("c", "c-x1y2", (QueryProfileRegistry) null);
test.addInherited(x1y2Parent, new String[] { "x1", "y2" });
test.set("c", "c-x1", new String[] { "x1" }, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals(null, ctest.get("c"));
assertEquals("c-x1", ctest.get("c", toMap("x=x1")));
assertEquals("c-x1", ctest.get("c", toMap("x=x1", "y=y1")));
assertEquals("c-x1y2", ctest.get("c", toMap("x=x1", "y=y2")));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantsOfExplicitCompound.
public void testVariantsOfExplicitCompound() {
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a.b", (QueryProfileRegistry) null);
QueryProfile profile = new QueryProfile("test");
profile.setDimensions(new String[] { "x" });
profile.set("a", a1, (QueryProfileRegistry) null);
profile.set("a.b", "a.b.x1", new String[] { "x1" }, null);
profile.set("a.b", "a.b.x2", new String[] { "x2" }, null);
CompiledQueryProfile cprofile = profile.compile(null);
assertEquals("a.b", cprofile.get("a.b"));
assertEquals("a.b.x1", cprofile.get("a.b", toMap("x=x1")));
assertEquals("a.b.x2", cprofile.get("a.b", toMap("x=x2")));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testIncompatibleDimensionsSimplified.
public void testIncompatibleDimensionsSimplified() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
backendBase.set("custid", "s", (QueryProfileRegistry) null);
QueryProfile backend = new QueryProfile("backend");
backend.setDimensions(new String[] { "sort", "lang", "fr", "entry" });
backend.set("custid", "yahoo/alerts", new String[] { null, "en-US", null, "alert" }, null);
backend.addInherited(backendBase);
QueryProfile web = new QueryProfile("web");
web.setDimensions(new String[] { "entry", "recency" });
web.set("fr", "alerts", new String[] { "alert" }, null);
alert.set("vertical", backend, (QueryProfileRegistry) null);
alert.set("multimedia", web, (QueryProfileRegistry) null);
CompiledQueryProfile cAlert = alert.compile(null);
assertEquals("yahoo/alerts", cAlert.get("vertical.custid", toMap("entry=alert", "intl=us", "lang=en-US")));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testListVariantPropertiesCompounds2.
public void testListVariantPropertiesCompounds2() {
QueryProfile parent1 = new QueryProfile("parent1");
// Defined everywhere
parent1.set("p1.a", "parent1-a", (QueryProfileRegistry) null);
// Defined everywhere, but no variants
parent1.set("p1.b", "parent1-b", (QueryProfileRegistry) null);
// Defined in both parents only
parent1.set("p1.c", "parent1-c", (QueryProfileRegistry) null);
QueryProfile parent2 = new QueryProfile("parent2");
parent2.set("p1.a", "parent2-a", (QueryProfileRegistry) null);
parent2.set("p1.b", "parent2-b", (QueryProfileRegistry) null);
parent2.set("p1.c", "parent2-c", (QueryProfileRegistry) null);
// Defined in second parent only
parent2.set("p1.d", "parent2-d", (QueryProfileRegistry) null);
QueryProfile main = new QueryProfile("main");
main.setDimensions(new String[] { "x", "y" });
main.addInherited(parent1);
main.addInherited(parent2);
main.set("p1.a", "main-a", (QueryProfileRegistry) null);
main.set("p1.a", "main-a-x1", new String[] { "x1" }, null);
// Defined in two variants only
main.set("p1.e", "main-e-x1", new String[] { "x1" }, null);
// Defined in one variants only
main.set("p1.f", "main-f-x1", new String[] { "x1" }, null);
main.set("p1.a", "main-a-x1.y1", new String[] { "x1", "y1" }, null);
main.set("p1.a", "main-a-x1.y2", new String[] { "x1", "y2" }, null);
main.set("p1.e", "main-e-x1.y2", new String[] { "x1", "y2" }, null);
// Defined in one variant only
main.set("p1.g", "main-g-x1.y2", new String[] { "x1", "y2" }, null);
main.set("p1.b", "main-b", (QueryProfileRegistry) null);
QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
inheritedVariant1.set("p1.a", "inheritedVariant1-a", (QueryProfileRegistry) null);
// Only defined in two inherited variants
inheritedVariant1.set("p1.h", "inheritedVariant1-h", (QueryProfileRegistry) null);
QueryProfile inheritedVariant2 = new QueryProfile("inheritedVariant2");
inheritedVariant2.set("p1.a", "inheritedVariant2-a", (QueryProfileRegistry) null);
// Only defined in two inherited variants
inheritedVariant2.set("p1.h", "inheritedVariant2-h", (QueryProfileRegistry) null);
// Only defined in one inherited variant
inheritedVariant2.set("p1.i", "inheritedVariant2-i", (QueryProfileRegistry) null);
QueryProfile inheritedVariant3 = new QueryProfile("inheritedVariant3");
// Only defined in one inherited variant, but inherited twice
inheritedVariant3.set("p1.j", "inheritedVariant3-j", (QueryProfileRegistry) null);
main.addInherited(inheritedVariant1, new String[] { "x1" });
main.addInherited(inheritedVariant3, new String[] { "x1" });
main.addInherited(inheritedVariant2, new String[] { "x1", "y2" });
main.addInherited(inheritedVariant3, new String[] { "x1", "y2" });
Properties properties = new QueryProfileProperties(main.compile(null));
int expectedBaseSize = 4;
// No context
Map<String, Object> listed = properties.listProperties();
assertEquals(expectedBaseSize, listed.size());
assertEquals("main-a", listed.get("p1.a"));
assertEquals("main-b", listed.get("p1.b"));
assertEquals("parent1-c", listed.get("p1.c"));
assertEquals("parent2-d", listed.get("p1.d"));
// Context x=x1
listed = properties.listProperties(toMap(main, new String[] { "x1" }));
assertEquals(expectedBaseSize + 4, listed.size());
assertEquals("main-a-x1", listed.get("p1.a"));
assertEquals("main-b", listed.get("p1.b"));
assertEquals("parent1-c", listed.get("p1.c"));
assertEquals("parent2-d", listed.get("p1.d"));
assertEquals("main-e-x1", listed.get("p1.e"));
assertEquals("main-f-x1", listed.get("p1.f"));
assertEquals("inheritedVariant1-h", listed.get("p1.h"));
assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y1
listed = properties.listProperties(toMap(main, new String[] { "x1", "y1" }));
assertEquals(expectedBaseSize + 4, listed.size());
assertEquals("main-a-x1.y1", listed.get("p1.a"));
assertEquals("main-b", listed.get("p1.b"));
assertEquals("parent1-c", listed.get("p1.c"));
assertEquals("parent2-d", listed.get("p1.d"));
assertEquals("main-e-x1", listed.get("p1.e"));
assertEquals("main-f-x1", listed.get("p1.f"));
assertEquals("inheritedVariant1-h", listed.get("p1.h"));
assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y2
listed = properties.listProperties(toMap(main, new String[] { "x1", "y2" }));
assertEquals(expectedBaseSize + 6, listed.size());
assertEquals("main-a-x1.y2", listed.get("p1.a"));
assertEquals("main-b", listed.get("p1.b"));
assertEquals("parent1-c", listed.get("p1.c"));
assertEquals("parent2-d", listed.get("p1.d"));
assertEquals("main-e-x1.y2", listed.get("p1.e"));
assertEquals("main-f-x1", listed.get("p1.f"));
assertEquals("main-g-x1.y2", listed.get("p1.g"));
assertEquals("inheritedVariant2-h", listed.get("p1.h"));
assertEquals("inheritedVariant2-i", listed.get("p1.i"));
assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y3
listed = properties.listProperties(toMap(main, new String[] { "x1", "y3" }));
assertEquals(expectedBaseSize + 4, listed.size());
assertEquals("main-a-x1", listed.get("p1.a"));
assertEquals("main-b", listed.get("p1.b"));
assertEquals("parent1-c", listed.get("p1.c"));
assertEquals("parent2-d", listed.get("p1.d"));
assertEquals("main-e-x1", listed.get("p1.e"));
assertEquals("main-f-x1", listed.get("p1.f"));
assertEquals("inheritedVariant1-h", listed.get("p1.h"));
assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x2,y=y1
listed = properties.listProperties(toMap(main, new String[] { "x2", "y1" }));
assertEquals(expectedBaseSize, listed.size());
assertEquals("main-a", listed.get("p1.a"));
assertEquals("main-b", listed.get("p1.b"));
assertEquals("parent1-c", listed.get("p1.c"));
assertEquals("parent2-d", listed.get("p1.d"));
}
Aggregations