use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTypeInheritanceTestCase method testStrictIsInherited.
public void testStrictIsInherited() {
type.inherited().add(userStrict);
type.freeze();
userStrict.freeze();
QueryProfile test = new QueryProfile("test");
test.setType(type);
test.set("myUserInteger", "37", (QueryProfileRegistry) null);
try {
test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
fail("Should have failed");
} catch (IllegalArgumentException e) {
assertEquals("'myUnknownInteger' is not declared in query profile type 'testtype', and the type is strict", e.getCause().getMessage());
}
CompiledQueryProfile ctest = test.compile(null);
assertEquals(37, ctest.get("myUserInteger"));
assertNull(ctest.get("myUnknownInteger"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testIncompatibleDimensions.
public void testIncompatibleDimensions() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
backendBase.setDimensions(new String[] { "sort", "resulttypes", "rss" });
backendBase.set("custid", "s", (QueryProfileRegistry) null);
QueryProfile backend = new QueryProfile("backend");
backend.setDimensions(new String[] { "sort", "offset", "resulttypes", "rss", "age", "lang", "fr", "entry" });
backend.addInherited(backendBase);
QueryProfile web = new QueryProfile("web");
web.setDimensions(new String[] { "entry", "recency" });
web.set("fr", "alerts", new String[] { "alert" }, null);
alert.set("config.backend.vertical.news", backend, (QueryProfileRegistry) null);
alert.set("config.backend.multimedia", web, (QueryProfileRegistry) null);
backend.set("custid", "yahoo/alerts", new String[] { null, null, null, null, null, "en-US", null, "alert" }, null);
CompiledQueryProfile cAlert = alert.compile(null);
assertEquals("yahoo/alerts", cAlert.get("config.backend.vertical.news.custid", toMap("entry=alert", "intl=us", "lang=en-US")));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantInheritanceWithCompoundReferences.
public void testVariantInheritanceWithCompoundReferences() {
QueryProfile test = new QueryProfile("test");
test.setDimensions(new String[] { "x" });
test.set("a.b", "default-a.b", (QueryProfileRegistry) null);
QueryProfile ac = new QueryProfile("ac");
ac.set("a.c", "referenced-a.c", (QueryProfileRegistry) null);
test.addInherited(ac, new String[] { "x1" });
test.set("a.b", "x1-a.b", new String[] { "x1" }, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("Basic functionality", "default-a.b", ctest.get("a.b"));
assertEquals("Inherited variance reference works", "referenced-a.c", ctest.get("a.c", toMap("x=x1")));
assertEquals("Inherited variance reference overriding works", "x1-a.b", ctest.get("a.b", toMap("x=x1")));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel.
public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel() {
QueryProfile test = new QueryProfile("test");
test.setDimensions(new String[] { "x" });
test.set("o.a.b", "default-a.b", (QueryProfileRegistry) null);
QueryProfile ac = new QueryProfile("ac");
ac.set("o.a.c", "referenced-a.c", (QueryProfileRegistry) null);
test.addInherited(ac, new String[] { "x1" });
test.set("o.a.b", "x1-a.b", new String[] { "x1" }, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("Basic functionality", "default-a.b", ctest.get("o.a.b"));
assertEquals("Inherited variance reference works", "referenced-a.c", ctest.get("o.a.c", toMap("x=x1")));
assertEquals("Inherited variance reference overriding works", "x1-a.b", ctest.get("o.a.b", toMap("x=x1")));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantsAreResolvedBeforeInheritance.
public void testVariantsAreResolvedBeforeInheritance() {
QueryProfile parent = new QueryProfile("parent");
parent.setDimensions(new String[] { "x", "y" });
parent.set("a", "p.a.default", (QueryProfileRegistry) null);
parent.set("a", "p.a.x1.y1", new String[] { "x1", "y1" }, null);
parent.set("a", "p.a.x1.y2", new String[] { "x1", "y2" }, null);
parent.set("b", "p.b.default", (QueryProfileRegistry) null);
parent.set("b", "p.b.x1.y1", new String[] { "x1", "y1" }, null);
parent.set("b", "p.b.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);
child.set("a", "c.a.x1.y1", new String[] { "x1", "y1" }, null);
CompiledQueryProfile cchild = child.compile(null);
assertEquals("c.a.default", cchild.get("a"));
assertEquals("c.a.x1.y1", cchild.get("a", toMap("x=x1", "y=y1")));
assertEquals("c.a.default", cchild.get("a", toMap("x=x1", "y=y2")));
assertEquals("p.b.default", cchild.get("b"));
assertEquals("p.b.x1.y1", cchild.get("b", toMap("x=x1", "y=y1")));
assertEquals("p.b.x1.y2", cchild.get("b", toMap("x=x1", "y=y2")));
}
Aggregations