use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantNotInBaseSpaceVariantValue.
public void testVariantNotInBaseSpaceVariantValue() {
QueryProfile test = new QueryProfile("test");
test.setDimensions(new String[] { "x" });
test.set("InX1Only", "x1", new String[] { "x 1" }, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("x1", ctest.get("InX1Only", toMap("x=x 1")));
assertEquals(null, ctest.get("InX1Only", toMap("x=x 2")));
assertEquals(null, ctest.get("InX1Only"));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel.
public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel() {
QueryProfile test = new QueryProfile("test");
test.setDimensions(new String[] { "x" });
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);
QueryProfile top = new QueryProfile("top");
top.set("o.a.b", "default-a.b", (QueryProfileRegistry) null);
top.set("o", test, (QueryProfileRegistry) null);
CompiledQueryProfile ctop = top.compile(null);
assertEquals("Basic functionality", "default-a.b", ctop.get("o.a.b"));
assertEquals("Inherited variance reference works", "referenced-a.c", ctop.get("o.a.c", toMap("x=x1")));
// Note: Changed from x1-a.b in 4.2.3
assertEquals("Inherited variance reference does not override value set in referent", "default-a.b", ctop.get("o.a.b", toMap("x=x1")));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testDimensionsInSuperType.
public void testDimensionsInSuperType() {
QueryProfile parent = new QueryProfile("parent");
parent.setDimensions(new String[] { "x", "y" });
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
child.set("a", "a.default", (QueryProfileRegistry) null);
child.set("a", "a.x1.y1", new String[] { "x1", "y1" }, null);
child.set("a", "a.x1.y2", new String[] { "x1", "y2" }, null);
CompiledQueryProfile cchild = child.compile(null);
assertEquals("a.default", cchild.get("a"));
assertEquals("a.x1.y1", cchild.get("a", toMap("x=x1", "y=y1")));
assertEquals("a.x1.y2", cchild.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 testVariantInheritanceOverridesBaseInheritanceComplex.
public void testVariantInheritanceOverridesBaseInheritanceComplex() {
QueryProfile defaultQP = new QueryProfile("default");
defaultQP.set("model.defaultIndex", "title", (QueryProfileRegistry) null);
QueryProfile root = new QueryProfile("root");
root.addInherited(defaultQP);
root.set("model.defaultIndex", "default", (QueryProfileRegistry) null);
QueryProfile querybest = new QueryProfile("querybest");
querybest.set("defaultIndex", "title", (QueryProfileRegistry) null);
querybest.set("queryString", "best", (QueryProfileRegistry) null);
QueryProfile multi = new QueryProfile("multi");
multi.setDimensions(new String[] { "x" });
multi.addInherited(defaultQP);
multi.set("model", querybest, (QueryProfileRegistry) null);
multi.addInherited(root, new String[] { "x1" });
multi.set("model.queryString", "love", new String[] { "x1" }, null);
// Rumtimize
defaultQP.freeze();
root.freeze();
querybest.freeze();
multi.freeze();
Properties runtime = new QueryProfileProperties(multi.compile(null));
assertEquals("default", runtime.get("model.defaultIndex", toMap("x=x1")));
assertEquals("love", runtime.get("model.queryString", toMap("x=x1")));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testQueryProfileReferences.
public void testQueryProfileReferences() {
QueryProfile main = new QueryProfile("main");
main.setDimensions(new String[] { "x1" });
QueryProfile referencedMain = new QueryProfile("referencedMain");
// In both
referencedMain.set("r1", "mainReferenced-r1", (QueryProfileRegistry) null);
// Only in this
referencedMain.set("r2", "mainReferenced-r2", (QueryProfileRegistry) null);
QueryProfile referencedVariant = new QueryProfile("referencedVariant");
// In both
referencedVariant.set("r1", "variantReferenced-r1", (QueryProfileRegistry) null);
// Only in this
referencedVariant.set("r3", "variantReferenced-r3", (QueryProfileRegistry) null);
main.set("a", referencedMain, (QueryProfileRegistry) null);
main.set("a", referencedVariant, new String[] { "x1" }, null);
Properties properties = new QueryProfileProperties(main.compile(null));
// No context
Map<String, Object> listed = properties.listProperties();
assertEquals(2, listed.size());
assertEquals("mainReferenced-r1", listed.get("a.r1"));
assertEquals("mainReferenced-r2", listed.get("a.r2"));
// Context x=x1
listed = properties.listProperties(toMap(main, new String[] { "x1" }));
assertEquals(3, listed.size());
assertEquals("variantReferenced-r1", listed.get("a.r1"));
assertEquals("mainReferenced-r2", listed.get("a.r2"));
assertEquals("variantReferenced-r3", listed.get("a.r3"));
}
Aggregations