Search in sources :

Example 16 with QueryProfileProperties

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"));
}
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 17 with QueryProfileProperties

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

Example 18 with QueryProfileProperties

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

Example 19 with QueryProfileProperties

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")));
}
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 20 with QueryProfileProperties

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"));
}
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)

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