use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testInheritance3Level.
public void testInheritance3Level() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
QueryProfile mormor = new QueryProfile("mormor");
QueryProfile morfar = new QueryProfile("morfar");
QueryProfile farfar = new QueryProfile("farfar");
barn.addInherited(mor);
barn.addInherited(far);
mor.addInherited(mormor);
mor.addInherited(morfar);
far.addInherited(farfar);
morfar.set("y.a.x", "morfar-a", (QueryProfileRegistry) null);
mormor.set("y.a.x", "mormor-a", (QueryProfileRegistry) null);
farfar.set("y.a.x", "farfar-a", (QueryProfileRegistry) null);
mor.set("y.a.x", "mor-a", (QueryProfileRegistry) null);
far.set("y.a.x", "far-a", (QueryProfileRegistry) null);
barn.set("y.a.x", "barn-a", (QueryProfileRegistry) null);
mormor.set("y.b.x", "mormor-b", (QueryProfileRegistry) null);
far.set("y.b.x", "far-b", (QueryProfileRegistry) null);
mor.set("y.c.x", "mor-c", (QueryProfileRegistry) null);
far.set("y.c.x", "far-c", (QueryProfileRegistry) null);
mor.set("y.d.a.x", "mor-d.a", (QueryProfileRegistry) null);
barn.set("y.d.b.x", "barn-d.b", (QueryProfileRegistry) null);
QueryProfile annetBarn = new QueryProfile("annetBarn");
annetBarn.set("venn", barn, (QueryProfileRegistry) null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
assertEquals("barn-a", cbarn.get("y.a.x"));
assertEquals("mormor-b", cbarn.get("y.b.x"));
assertEquals("mor-c", cbarn.get("y.c.x"));
assertEquals("barn-a", cannetBarn.get("venn.y.a.x"));
assertEquals("mormor-b", cannetBarn.get("venn.y.b.x"));
assertEquals("mor-c", cannetBarn.get("venn.y.c.x"));
assertEquals("barn-d.b", cbarn.get("y.d.b.x"));
assertEquals("mor-d.a", cbarn.get("y.d.a.x"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testRankTypeNames.
public void testRankTypeNames() {
QueryProfile p = new QueryProfile("test");
p.set("a.$b", "foo", (QueryProfileRegistry) null);
p.set("a.query(b)", "bar", (QueryProfileRegistry) null);
p.set("a.b.default-index", "fuu", (QueryProfileRegistry) null);
CompiledQueryProfile cp = p.compile(null);
assertEquals("foo", cp.get("a.$b"));
assertEquals("bar", cp.get("a.query(b)"));
assertEquals("fuu", cp.get("a.b.default-index"));
Map<String, Object> p1 = cp.listValues("");
assertEquals("foo", p1.get("a.$b"));
assertEquals("bar", p1.get("a.query(b)"));
assertEquals("fuu", p1.get("a.b.default-index"));
Map<String, Object> p2 = cp.listValues("a");
assertEquals("foo", p2.get("$b"));
assertEquals("bar", p2.get("query(b)"));
assertEquals("fuu", p2.get("b.default-index"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testBasics.
public void testBasics() {
QueryProfile profile = new QueryProfile("test");
profile.set("a", "a-value", (QueryProfileRegistry) null);
profile.set("b.c", "b.c-value", (QueryProfileRegistry) null);
profile.set("d.e.f", "d.e.f-value", (QueryProfileRegistry) null);
CompiledQueryProfile cprofile = profile.compile(null);
assertEquals("a-value", cprofile.get("a"));
assertEquals("b.c-value", cprofile.get("b.c"));
assertEquals("d.e.f-value", cprofile.get("d.e.f"));
assertNull(cprofile.get("nonexistent"));
assertNull(cprofile.get("nested.nonexistent"));
assertTrue(profile.lookup("b", null).getClass() == QueryProfile.class);
assertTrue(profile.lookup("b", null).getClass() == QueryProfile.class);
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testGetSubObjects.
public void testGetSubObjects() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
QueryProfile mormor = new QueryProfile("mormor");
QueryProfile morfar = new QueryProfile("morfar");
QueryProfile farfar = new QueryProfile("farfar");
mor.addInherited(mormor);
mor.addInherited(morfar);
far.addInherited(farfar);
barn.addInherited(mor);
barn.addInherited(far);
mormor.set("a.mormor", "a.mormor", (QueryProfileRegistry) null);
barn.set("a.barn", "a.barn", (QueryProfileRegistry) null);
mor.set("b.mor", "b.mor", (QueryProfileRegistry) null);
far.set("b.far", "b.far", (QueryProfileRegistry) null);
far.set("a.far", "a.far", (QueryProfileRegistry) null);
CompiledQueryProfile cbarn = barn.compile(null);
assertSameObjects(cbarn, "a", Arrays.asList("mormor", "far", "barn"));
assertEquals("b.mor", cbarn.get("b.mor"));
assertEquals("b.far", cbarn.get("b.far"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantInheritance.
public void testVariantInheritance() {
QueryProfile test = new QueryProfile("test");
test.setDimensions(new String[] { "x", "y" });
QueryProfile defaultParent = new QueryProfile("defaultParent");
defaultParent.set("a", "a-default", (QueryProfileRegistry) null);
QueryProfile x1Parent = new QueryProfile("x1Parent");
x1Parent.set("a", "a-x1", (QueryProfileRegistry) null);
x1Parent.set("d", "d-x1", (QueryProfileRegistry) null);
x1Parent.set("e", "e-x1", (QueryProfileRegistry) null);
QueryProfile x1y1Parent = new QueryProfile("x1y1Parent");
x1y1Parent.set("a", "a-x1y1", (QueryProfileRegistry) null);
QueryProfile x1y2Parent = new QueryProfile("x1y2Parent");
x1y2Parent.set("a", "a-x1y2", (QueryProfileRegistry) null);
x1y2Parent.set("b", "b-x1y2", (QueryProfileRegistry) null);
x1y2Parent.set("c", "c-x1y2", (QueryProfileRegistry) null);
test.addInherited(defaultParent);
test.addInherited(x1Parent, new String[] { "x1" });
test.addInherited(x1y1Parent, new String[] { "x1", "y1" });
test.addInherited(x1y2Parent, new String[] { "x1", "y2" });
test.set("c", "c-x1", new String[] { "x1" }, null);
test.set("e", "e-x1y2", new String[] { "x1", "y2" }, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("a-default", ctest.get("a"));
assertEquals("a-x1", ctest.get("a", toMap("x=x1")));
assertEquals("a-x1y1", ctest.get("a", toMap("x=x1", "y=y1")));
assertEquals("a-x1y2", ctest.get("a", toMap("x=x1", "y=y2")));
assertEquals(null, ctest.get("b"));
assertEquals(null, ctest.get("b", toMap("x=x1")));
assertEquals(null, ctest.get("b", toMap("x=x1", "y=y1")));
assertEquals("b-x1y2", ctest.get("b", toMap("x=x1", "y=y2")));
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")));
assertEquals(null, ctest.get("d"));
assertEquals("d-x1", ctest.get("d", toMap("x=x1")));
assertEquals("d-x1", ctest.get("d", toMap("x=x1", "y=y1")));
assertEquals("d-x1", ctest.get("d", toMap("x=x1", "y=y2")));
assertEquals(null, ctest.get("d"));
assertEquals("e-x1", ctest.get("e", toMap("x=x1")));
assertEquals("e-x1", ctest.get("e", toMap("x=x1", "y=y1")));
assertEquals("e-x1y2", ctest.get("e", toMap("x=x1", "y=y2")));
}
Aggregations