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