use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testListVariantPropertiesCompounds1Simplified.
public void testListVariantPropertiesCompounds1Simplified() {
QueryProfile main = new QueryProfile("main");
main.setDimensions(new String[] { "x", "y" });
main.set("a.p1", "main-a-x1", new String[] { "x1" }, null);
QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
inheritedVariant1.set("a.p1", "inheritedVariant1-a", (QueryProfileRegistry) null);
main.addInherited(inheritedVariant1, new String[] { "x1" });
Properties properties = new QueryProfileProperties(main.compile(null));
// Context x=x1
Map<String, Object> listed = properties.listProperties(toMap(main, new String[] { "x1" }));
assertEquals("main-a-x1", listed.get("a.p1"));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testCompound.
public void testCompound() {
// Configuration phase
QueryProfile profile = new QueryProfile("test");
profile.setDimensions(new String[] { "x", "y" });
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a1.b.default", (QueryProfileRegistry) null);
a1.set("c", "a1.c.default", (QueryProfileRegistry) null);
a1.set("d", "a1.d.default", (QueryProfileRegistry) null);
a1.set("e", "a1.e.default", (QueryProfileRegistry) null);
QueryProfile a2 = new QueryProfile("a2");
a2.set("b", "a2.b.default", (QueryProfileRegistry) null);
a2.set("c", "a2.c.default", (QueryProfileRegistry) null);
a2.set("d", "a2.d.default", (QueryProfileRegistry) null);
a2.set("e", "a2.e.default", (QueryProfileRegistry) null);
// Must set profile references before overrides
profile.set("a", a1, (QueryProfileRegistry) null);
profile.set("a.b", "a.b.default-override", (QueryProfileRegistry) null);
profile.set("a.c", "a.c.default-override", (QueryProfileRegistry) null);
profile.set("a.d", "a.d.default-override", (QueryProfileRegistry) null);
profile.set("a.g", "a.g.default-override", (QueryProfileRegistry) null);
String[] d1 = new String[] { "x1", "y1" };
profile.set("a", a1, d1, null);
profile.set("a.b", "x1.y1.a.b.default-override", d1, null);
profile.set("a.c", "x1.y1.a.c.default-override", d1, null);
// This value is never manifest because the runtime override overrides all variants
profile.set("a.g", "x1.y1.a.g.default-override", d1, null);
String[] d2 = new String[] { "x1", "y2" };
profile.set("a.b", "x1.y2.a.b.default-override", d2, null);
profile.set("a.c", "x1.y2.a.c.default-override", d2, null);
String[] d3 = new String[] { "x2", "y1" };
profile.set("a", a2, d3, null);
profile.set("a.b", "x2.y1.a.b.default-override", d3, null);
profile.set("a.c", "x2.y1.a.c.default-override", d3, null);
// Runtime phase - four simultaneous requests using different variants makes their own overrides
QueryProfileProperties defaultRuntimeProfile = new QueryProfileProperties(profile.compile(null));
defaultRuntimeProfile.set("a.f", "a.f.runtime-override");
defaultRuntimeProfile.set("a.g", "a.g.runtime-override");
QueryProfileProperties d1RuntimeProfile = new QueryProfileProperties(profile.compile(null));
d1RuntimeProfile.set("a.f", "a.f.d1.runtime-override", toMap("x=x1", "y=y1"));
d1RuntimeProfile.set("a.g", "a.g.d1.runtime-override", toMap("x=x1", "y=y1"));
QueryProfileProperties d2RuntimeProfile = new QueryProfileProperties(profile.compile(null));
d2RuntimeProfile.set("a.f", "a.f.d2.runtime-override", toMap("x=x1", "y=y2"));
d2RuntimeProfile.set("a.g", "a.g.d2.runtime-override", toMap("x=x1", "y=y2"));
QueryProfileProperties d3RuntimeProfile = new QueryProfileProperties(profile.compile(null));
d3RuntimeProfile.set("a.f", "a.f.d3.runtime-override", toMap("x=x2", "y=y1"));
d3RuntimeProfile.set("a.g", "a.g.d3.runtime-override", toMap("x=x2", "y=y1"));
// Lookups
assertEquals("a.b.default-override", defaultRuntimeProfile.get("a.b"));
assertEquals("a.c.default-override", defaultRuntimeProfile.get("a.c"));
assertEquals("a.d.default-override", defaultRuntimeProfile.get("a.d"));
assertEquals("a1.e.default", defaultRuntimeProfile.get("a.e"));
assertEquals("a.f.runtime-override", defaultRuntimeProfile.get("a.f"));
assertEquals("a.g.runtime-override", defaultRuntimeProfile.get("a.g"));
assertEquals("x1.y1.a.b.default-override", d1RuntimeProfile.get("a.b", toMap("x=x1", "y=y1")));
assertEquals("x1.y1.a.c.default-override", d1RuntimeProfile.get("a.c", toMap("x=x1", "y=y1")));
assertEquals("a1.d.default", d1RuntimeProfile.get("a.d", toMap("x=x1", "y=y1")));
assertEquals("a1.e.default", d1RuntimeProfile.get("a.e", toMap("x=x1", "y=y1")));
assertEquals("a.f.d1.runtime-override", d1RuntimeProfile.get("a.f", toMap("x=x1", "y=y1")));
assertEquals("a.g.d1.runtime-override", d1RuntimeProfile.get("a.g", toMap("x=x1", "y=y1")));
assertEquals("x1.y2.a.b.default-override", d2RuntimeProfile.get("a.b", toMap("x=x1", "y=y2")));
assertEquals("x1.y2.a.c.default-override", d2RuntimeProfile.get("a.c", toMap("x=x1", "y=y2")));
// Because this variant does not itself refer to a
assertEquals("a.d.default-override", d2RuntimeProfile.get("a.d", toMap("x=x1", "y=y2")));
assertEquals("a1.e.default", d2RuntimeProfile.get("a.e", toMap("x=x1", "y=y2")));
assertEquals("a.f.d2.runtime-override", d2RuntimeProfile.get("a.f", toMap("x=x1", "y=y2")));
assertEquals("a.g.d2.runtime-override", d2RuntimeProfile.get("a.g", toMap("x=x1", "y=y2")));
assertEquals("x2.y1.a.b.default-override", d3RuntimeProfile.get("a.b", toMap("x=x2", "y=y1")));
assertEquals("x2.y1.a.c.default-override", d3RuntimeProfile.get("a.c", toMap("x=x2", "y=y1")));
assertEquals("a2.d.default", d3RuntimeProfile.get("a.d", toMap("x=x2", "y=y1")));
assertEquals("a2.e.default", d3RuntimeProfile.get("a.e", toMap("x=x2", "y=y1")));
assertEquals("a.f.d3.runtime-override", d3RuntimeProfile.get("a.f", toMap("x=x2", "y=y1")));
assertEquals("a.g.d3.runtime-override", d3RuntimeProfile.get("a.g", toMap("x=x2", "y=y1")));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileConfigurationTestCase method testBug3197426.
@Test
public void testBug3197426() {
QueryProfileConfigurer configurer = new QueryProfileConfigurer("file:" + CONFIG_DIR + "bug3197426.cfg");
CompiledQueryProfile profile = configurer.getCurrentRegistry().getComponent("default").compile(null);
Map<String, Object> properties = new QueryProfileProperties(profile).listProperties("source.image");
assertEquals("yes", properties.get("mlr"));
assertEquals("zh-Hant", properties.get("language"));
assertEquals("tw", properties.get("custid2"));
assertEquals("4", properties.get("hits"));
assertEquals("0", properties.get("offset"));
assertEquals("image", properties.get("catalog"));
assertEquals("yahoo", properties.get("custid1"));
assertEquals("utf-8", properties.get("encoding"));
assertEquals("all", properties.get("imquality"));
assertEquals("all", properties.get("dimensions"));
assertEquals("1", properties.get("flickr"));
assertEquals("yes", properties.get("ocr"));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileSubstitutionTestCase method testNoOverridingOfPropertiesSetAtRuntime.
public void testNoOverridingOfPropertiesSetAtRuntime() {
QueryProfile p = new QueryProfile("test");
p.set("message", "Hello %{world}!", (QueryProfileRegistry) null);
p.set("world", "world", (QueryProfileRegistry) null);
p.freeze();
Properties runtime = new QueryProfileProperties(p.compile(null));
runtime.set("runtimeMessage", "Hello %{world}!");
assertEquals("Hello world!", runtime.get("message"));
assertEquals("Hello %{world}!", runtime.get("runtimeMessage"));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileSubstitutionTestCase method testButPropertiesSetAtRuntimeAreUsedInSubstitutions.
public void testButPropertiesSetAtRuntimeAreUsedInSubstitutions() {
QueryProfile p = new QueryProfile("test");
p.set("message", "Hello %{world}!", (QueryProfileRegistry) null);
p.set("world", "world", (QueryProfileRegistry) null);
Properties runtime = new QueryProfileProperties(p.compile(null));
runtime.set("world", "Earth");
assertEquals("Hello Earth!", runtime.get("message"));
}
Aggregations