Search in sources :

Example 1 with CompoundName

use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.

the class CompoundNameBenchmark method createCompundName.

private final int createCompundName(String[] strings) {
    int retval = 0;
    for (int i = 0; i < strings.length; i++) {
        CompoundName n = new CompoundName(strings[i]);
        retval += n.size();
    }
    return retval;
}
Also used : CompoundName(com.yahoo.processing.request.CompoundName)

Example 2 with CompoundName

use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.

the class AllValuesQueryProfileVisitor method putValue.

private final void putValue(String key, Object value, Map<String, Object> values) {
    if (value == null)
        return;
    CompoundName fullName = currentPrefix.append(key);
    // Avoid putting a non-leaf (subtree) root in the list
    if (fullName.isEmpty())
        return;
    // The first value encountered has priority
    if (values.containsKey(fullName.toString()))
        return;
    values.put(fullName.toString(), value);
}
Also used : CompoundName(com.yahoo.processing.request.CompoundName)

Example 3 with CompoundName

use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.

the class QueryProfileProperties method unalias.

CompoundName unalias(CompoundName name, Map<String, String> context) {
    if (profile.getTypes().isEmpty())
        return name;
    CompoundName unaliasedName = name;
    for (int i = 0; i < name.size(); i++) {
        QueryProfileType type = profile.getType(name.first(i), context);
        if (type == null)
            continue;
        // TODO: Make never null
        if (type.aliases() == null)
            continue;
        if (type.aliases().isEmpty())
            continue;
        String localName = name.get(i);
        String unaliasedLocalName = type.unalias(localName);
        unaliasedName = unaliasedName.set(i, unaliasedLocalName);
    }
    return unaliasedName;
}
Also used : CompoundName(com.yahoo.processing.request.CompoundName) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 4 with CompoundName

use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.

the class QueryProfileProperties method listProperties.

@Override
public Map<String, Object> listProperties(CompoundName path, Map<String, String> context, com.yahoo.processing.request.Properties substitution) {
    path = unalias(path, context);
    if (context == null)
        context = Collections.emptyMap();
    Map<String, Object> properties = profile.listValues(path, context, substitution);
    properties.putAll(super.listProperties(path, context, substitution));
    if (references != null) {
        for (Pair<CompoundName, CompiledQueryProfile> refEntry : references) {
            if (!refEntry.getFirst().hasPrefix(path.first(Math.min(refEntry.getFirst().size(), path.size()))))
                continue;
            CompoundName pathInReference;
            CompoundName prefixToReferenceKeys;
            if (refEntry.getFirst().size() > path.size()) {
                pathInReference = CompoundName.empty;
                prefixToReferenceKeys = refEntry.getFirst().rest(path.size());
            } else {
                pathInReference = path.rest(refEntry.getFirst().size());
                prefixToReferenceKeys = CompoundName.empty;
            }
            for (Map.Entry<String, Object> valueEntry : refEntry.getSecond().listValues(pathInReference, context, substitution).entrySet()) {
                properties.put(prefixToReferenceKeys.append(new CompoundName(valueEntry.getKey())).toString(), valueEntry.getValue());
            }
        }
    }
    if (values != null) {
        for (Map.Entry<CompoundName, Object> entry : values.entrySet()) {
            if (entry.getKey().hasPrefix(path))
                properties.put(entry.getKey().rest(path.size()).toString(), entry.getValue());
        }
    }
    return properties;
}
Also used : CompoundName(com.yahoo.processing.request.CompoundName) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) PropertyMap(com.yahoo.processing.request.properties.PropertyMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with CompoundName

use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.

the class CompoundNameTestCase method testHashCodeAndEquals.

@Test
public void testHashCodeAndEquals() {
    CompoundName n1 = new CompoundName("venn.d.a");
    CompoundName n2 = new CompoundName(n1.asList());
    assertEquals(n1.hashCode(), n2.hashCode());
    assertEquals(n1, n2);
}
Also used : CompoundName(com.yahoo.processing.request.CompoundName) Test(org.junit.Test)

Aggregations

CompoundName (com.yahoo.processing.request.CompoundName)22 Test (org.junit.Test)7 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)6 HashMap (java.util.HashMap)6 Map (java.util.Map)5 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)4 PropertyMap (com.yahoo.processing.request.properties.PropertyMap)2 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)2 HashSet (java.util.HashSet)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 Request (com.yahoo.processing.Request)1 Properties (com.yahoo.processing.request.Properties)1 Query (com.yahoo.search.Query)1 ModelObjectMap (com.yahoo.search.query.profile.ModelObjectMap)1 QueryProfile (com.yahoo.search.query.profile.QueryProfile)1 QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)1 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)1 SubstituteString (com.yahoo.search.query.profile.SubstituteString)1 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)1