Search in sources :

Example 21 with QueryProfileProperties

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"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Properties(com.yahoo.search.query.Properties) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 22 with QueryProfileProperties

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")));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 23 with QueryProfileProperties

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"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfileConfigurer(com.yahoo.search.query.profile.config.QueryProfileConfigurer) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Test(org.junit.Test)

Example 24 with QueryProfileProperties

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"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Properties(com.yahoo.processing.request.Properties) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 25 with QueryProfileProperties

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"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Properties(com.yahoo.processing.request.Properties) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Aggregations

QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)25 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)23 QueryProfile (com.yahoo.search.query.profile.QueryProfile)21 Properties (com.yahoo.search.query.Properties)9 BackedOverridableQueryProfile (com.yahoo.search.query.profile.BackedOverridableQueryProfile)9 Properties (com.yahoo.processing.request.Properties)3 ModelObjectMap (com.yahoo.search.query.profile.ModelObjectMap)2 PropertyMap (com.yahoo.search.query.properties.PropertyMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 CompoundName (com.yahoo.processing.request.CompoundName)1 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)1 QueryProfileConfigurer (com.yahoo.search.query.profile.config.QueryProfileConfigurer)1 DefaultProperties (com.yahoo.search.query.properties.DefaultProperties)1 QueryProperties (com.yahoo.search.query.properties.QueryProperties)1 RequestContextProperties (com.yahoo.search.query.properties.RequestContextProperties)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1