use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.
the class CompiledQueryProfile method listValues.
/**
* Adds all objects that start with the given path prefix to the given value map. Use "" to list all.
* <p>
* For example, if {a.d => "a.d-value" ,a.e => "a.e-value", b.d => "b.d-value", then calling listValues("a")
* will return {"d" => "a.d-value","e" => "a.e-value"}
*/
public Map<String, Object> listValues(CompoundName prefix, Map<String, String> context, Properties substitution) {
Map<String, Object> values = new HashMap<>();
for (Map.Entry<CompoundName, DimensionalValue<Object>> entry : entries.entrySet()) {
if (entry.getKey().size() <= prefix.size())
continue;
if (!entry.getKey().hasPrefix(prefix))
continue;
Object value = entry.getValue().get(context);
if (value == null)
continue;
value = substitute(value, context, substitution);
CompoundName suffixName = entry.getKey().rest(prefix.size());
values.put(suffixName.toString(), value);
}
return values;
}
use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.
the class FederationSearcher method getProperty.
private Object getProperty(Query query, CompoundKey key) {
CompoundName name = map.get(key);
if (name == null) {
name = new CompoundName(key.toString());
map.put(key, name);
}
return query.properties().get(name);
}
use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.
the class Query method traceProperties.
/**
* Traces how properties was resolved and from where. Done after the fact to avoid special handling
* of tracelevel, which is the property deciding whether this needs to be done
*/
private void traceProperties() {
if (traceLevel == 0)
return;
CompiledQueryProfile profile = null;
QueryProfileProperties profileProperties = properties().getInstance(QueryProfileProperties.class);
if (profileProperties != null)
profile = profileProperties.getQueryProfile();
if (profile == null)
trace("No query profile is used", false, 1);
else
trace("Using " + profile.toString(), false, 1);
if (traceLevel < 4)
return;
StringBuilder b = new StringBuilder("Resolved properties:\n");
Set<String> mentioned = new HashSet<>();
for (Map.Entry<String, String> requestProperty : requestProperties().entrySet()) {
Object resolvedValue = properties().get(requestProperty.getKey(), requestProperties());
if (resolvedValue == null && requestProperty.getKey().equals("queryProfile"))
resolvedValue = requestProperty.getValue();
b.append(requestProperty.getKey());
b.append("=");
// (may be null)
b.append(String.valueOf(resolvedValue));
b.append(" (");
if (profile != null && !profile.isOverridable(new CompoundName(requestProperty.getKey()), requestProperties()))
b.append("value from query profile - unoverridable, ignoring request value");
else
b.append("value from request");
b.append(")\n");
mentioned.add(requestProperty.getKey());
}
if (profile != null) {
appendQueryProfileProperties(profile, mentioned, b);
}
trace(b.toString(), false, 4);
}
use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.
the class QueryProfileType method addField.
/**
* Adds a field to this
*
* @throws IllegalStateException if this is frozen
*/
public void addField(FieldDescription fieldDescription, QueryProfileTypeRegistry registry) {
CompoundName name = fieldDescription.getCompoundName();
if (name.isCompound()) {
// Add (/to) a query profile type containing the rest of the name.
// (we do not need the field description settings for intermediate query profile types
// as the leaf entry will enforce them)
QueryProfileType type = getOrCreateQueryProfileType(name.first(), registry);
type.addField(fieldDescription.withName(name.rest()), registry);
} else {
ensureNotFrozen();
fields.put(fieldDescription.getName(), fieldDescription);
}
for (String alias : fieldDescription.getAliases()) addAlias(alias, fieldDescription.getName());
}
use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.
the class QueryProfileGetMicroBenchmark method getValues.
private void getValues(int count, Query query) {
final int dotInterval = 10000000;
CompoundName found = new CompoundName(propertyPrefix + "property1");
CompoundName notFound = new CompoundName(propertyPrefix + "nonExisting");
for (int i = 0; i < count; i++) {
if (count > dotInterval && i % (count / dotInterval) == 0)
System.out.print(".");
if (null == query.properties().get(found))
throw new RuntimeException("Expected value");
if (null != query.properties().get(notFound))
throw new RuntimeException("Expected no value");
}
}
Aggregations