Search in sources :

Example 16 with QueryProfile

use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.

the class QueryProfileGetInComplexStructureMicroBenchmark method benchmark.

public void benchmark(int count, boolean useVariant) {
    QueryProfile main = createProfile(useVariant);
    Query query = new Query(QueryTestCase.httpEncode("?query=test&x=1&y=2"), main.compile(null));
    // warm-up
    getValues(100000, query);
    System.out.print(this + ": ");
    long startTime = System.currentTimeMillis();
    getValues(count, query);
    long endTime = System.currentTimeMillis();
    long totalTime = (endTime - startTime);
    // *2 because we do 2 gets
    System.out.println("Done in " + totalTime + " ms (" + ((float) totalTime * 1000 / (count * 2) + " microsecond per get)"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query)

Example 17 with QueryProfile

use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.

the class QueryProfileTestCase method testSettingNonLeaf4a.

public void testSettingNonLeaf4a() {
    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", (QueryProfileRegistry) null);
    QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
    assertEquals("a-value", cp.get("a"));
    assertNull(cp.get("a.b"));
    assertEquals("a-value", cp.get("a", 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 QueryProfile

use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.

the class QueryProfileTestCase method testInheritance.

public void testInheritance() {
    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("a", "morfar-a", (QueryProfileRegistry) null);
    mormor.set("a", "mormor-a", (QueryProfileRegistry) null);
    farfar.set("a", "farfar-a", (QueryProfileRegistry) null);
    mor.set("a", "mor-a", (QueryProfileRegistry) null);
    far.set("a", "far-a", (QueryProfileRegistry) null);
    barn.set("a", "barn-a", (QueryProfileRegistry) null);
    mormor.set("b", "mormor-b", (QueryProfileRegistry) null);
    far.set("b", "far-b", (QueryProfileRegistry) null);
    mor.set("c", "mor-c", (QueryProfileRegistry) null);
    far.set("c", "far-c", (QueryProfileRegistry) null);
    mor.set("d.a", "mor-d.a", (QueryProfileRegistry) null);
    barn.set("d.b", "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("a"));
    assertEquals("mormor-b", cbarn.get("b"));
    assertEquals("mor-c", cbarn.get("c"));
    assertEquals("barn-a", cannetBarn.get("venn.a"));
    assertEquals("mormor-b", cannetBarn.get("venn.b"));
    assertEquals("mor-c", cannetBarn.get("venn.c"));
    assertEquals("barn-d.b", cbarn.get("d.b"));
    assertEquals("mor-d.a", cbarn.get("d.a"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile)

Example 19 with QueryProfile

use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.

the class QueryProfileTestCase method testListProperties.

public void testListProperties() {
    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("a", "morfar-a", (QueryProfileRegistry) null);
    morfar.set("model.b", "morfar-model.b", (QueryProfileRegistry) null);
    mormor.set("a", "mormor-a", (QueryProfileRegistry) null);
    mormor.set("model.b", "mormor-model.b", (QueryProfileRegistry) null);
    farfar.set("a", "farfar-a", (QueryProfileRegistry) null);
    mor.set("a", "mor-a", (QueryProfileRegistry) null);
    far.set("a", "far-a", (QueryProfileRegistry) null);
    barn.set("a", "barn-a", (QueryProfileRegistry) null);
    mormor.set("b", "mormor-b", (QueryProfileRegistry) null);
    far.set("b", "far-b", (QueryProfileRegistry) null);
    mor.set("c", "mor-c", (QueryProfileRegistry) null);
    far.set("c", "far-c", (QueryProfileRegistry) null);
    CompiledQueryProfile cbarn = barn.compile(null);
    QueryProfileProperties properties = new QueryProfileProperties(cbarn);
    assertEquals("barn-a", cbarn.get("a"));
    assertEquals("mormor-b", cbarn.get("b"));
    Map<String, Object> rootMap = properties.listProperties();
    assertEquals("barn-a", rootMap.get("a"));
    assertEquals("mormor-b", rootMap.get("b"));
    assertEquals("mor-c", rootMap.get("c"));
    Map<String, Object> modelMap = properties.listProperties("model");
    assertEquals("mormor-model.b", modelMap.get("b"));
    QueryProfile annetBarn = new QueryProfile("annetBarn");
    annetBarn.set("venn", barn, (QueryProfileRegistry) null);
    CompiledQueryProfile cannetBarn = annetBarn.compile(null);
    Map<String, Object> annetBarnMap = new QueryProfileProperties(cannetBarn).listProperties();
    assertEquals("barn-a", annetBarnMap.get("venn.a"));
    assertEquals("mormor-b", annetBarnMap.get("venn.b"));
    assertEquals("mor-c", annetBarnMap.get("venn.c"));
    assertEquals("mormor-model.b", annetBarnMap.get("venn.model.b"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 20 with QueryProfile

use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.

the class QueryProfileTestCase method testSettingNonLeaf2.

public void testSettingNonLeaf2() {
    QueryProfile p = new QueryProfile("test");
    p.set("a.b", "a.b-value", (QueryProfileRegistry) null);
    p.set("a", "a-value", (QueryProfileRegistry) null);
    QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
    assertEquals("a-value", cp.get("a"));
    assertEquals("a.b-value", cp.get("a.b"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Aggregations

QueryProfile (com.yahoo.search.query.profile.QueryProfile)161 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)92 Query (com.yahoo.search.Query)63 BackedOverridableQueryProfile (com.yahoo.search.query.profile.BackedOverridableQueryProfile)35 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)28 Test (org.junit.Test)26 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)24 QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)21 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)12 Properties (com.yahoo.search.query.Properties)8 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 SubstituteString (com.yahoo.search.query.profile.SubstituteString)4 QueryProfilesConfig (com.yahoo.search.query.profile.config.QueryProfilesConfig)4 Element (org.w3c.dom.Element)4 QueryException (com.yahoo.prelude.query.QueryException)3 Properties (com.yahoo.processing.request.Properties)3 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)3 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)3 ComponentSpecification (com.yahoo.component.ComponentSpecification)2