use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileTestCase method testCloning.
/**
* Tests cloning, with wrappers used in production in place
*/
public void testCloning() {
QueryProfile classProfile = new QueryProfile("test");
classProfile.set("a", "aValue", (QueryProfileRegistry) null);
classProfile.set("b", 3, (QueryProfileRegistry) null);
Properties properties = new QueryProfileProperties(classProfile.compile(null));
Properties propertiesClone = properties.clone();
assertEquals("aValue", propertiesClone.get("a"));
assertEquals(3, propertiesClone.get("b"));
properties.set("a", "aNewValue");
assertEquals("aNewValue", properties.get("a"));
assertEquals("aValue", propertiesClone.get("a"));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileTestCase method testSettingNonLeaf5.
public void testSettingNonLeaf5() {
QueryProfile p = new QueryProfile("test");
p.setDimensions(new String[] { "x" });
p.set("a.b", "a.b-value", new String[] { "x1" }, null);
p.set("a", "a-value", new String[] { "x1" }, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(cp.get("a"));
assertNull(cp.get("a.b"));
assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] { "x1" })));
assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] { "x1" })));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileTestCase method testSettingNonLeaf3a.
public void testSettingNonLeaf3a() {
QueryProfile p = new QueryProfile("test");
p.setDimensions(new String[] { "x" });
p.set("a.b", "a.b-value", (QueryProfileRegistry) null);
p.set("a", "a-value", new String[] { "x1" }, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(p.get("a"));
assertEquals("a.b-value", cp.get("a.b"));
assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] { "x1" })));
assertEquals("a.b-value", cp.get("a.b", new String[] { "x1" }));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testDimensionsInSuperTypeRuntime.
public void testDimensionsInSuperTypeRuntime() {
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);
Properties overridable = new QueryProfileProperties(child.compile(null));
assertEquals("a.default", child.get("a"));
assertEquals("a.x1.y1", overridable.get("a", toMap("x=x1", "y=y1")));
assertEquals("a.x1.y2", overridable.get("a", toMap("x=x1", "y=y2")));
}
use of com.yahoo.search.query.profile.QueryProfileProperties in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testQueryProfileReferencesWithSubstitution.
public void testQueryProfileReferencesWithSubstitution() {
QueryProfile main = new QueryProfile("main");
main.setDimensions(new String[] { "x1" });
QueryProfile referencedMain = new QueryProfile("referencedMain");
// In both
referencedMain.set("r1", "%{prefix}mainReferenced-r1", (QueryProfileRegistry) null);
// Only in this
referencedMain.set("r2", "%{prefix}mainReferenced-r2", (QueryProfileRegistry) null);
QueryProfile referencedVariant = new QueryProfile("referencedVariant");
// In both
referencedVariant.set("r1", "%{prefix}variantReferenced-r1", (QueryProfileRegistry) null);
// Only in this
referencedVariant.set("r3", "%{prefix}variantReferenced-r3", (QueryProfileRegistry) null);
main.set("a", referencedMain, (QueryProfileRegistry) null);
main.set("a", referencedVariant, new String[] { "x1" }, null);
main.set("prefix", "mainPrefix:", (QueryProfileRegistry) null);
main.set("prefix", "variantPrefix:", new String[] { "x1" }, null);
Properties properties = new QueryProfileProperties(main.compile(null));
// No context
Map<String, Object> listed = properties.listProperties();
assertEquals(3, listed.size());
assertEquals("mainPrefix:mainReferenced-r1", listed.get("a.r1"));
assertEquals("mainPrefix:mainReferenced-r2", listed.get("a.r2"));
// Context x=x1
listed = properties.listProperties(toMap(main, new String[] { "x1" }));
assertEquals(4, listed.size());
assertEquals("variantPrefix:variantReferenced-r1", listed.get("a.r1"));
assertEquals("variantPrefix:mainReferenced-r2", listed.get("a.r2"));
assertEquals("variantPrefix:variantReferenced-r3", listed.get("a.r3"));
}
Aggregations