summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-28 16:47:42 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-28 17:42:10 +0200
commitf40248518010e55335925d13aeb5539da441fa78 (patch)
tree0f0037395bbee1a1f33457d272980c8b46d5a8b2 /container-search
parent46fee0b7694db400a73f2a4e53846a9047c9cd2a (diff)
- Avoid creating a lot of temporary CompoundNames by caching them.
- This speeds up creation of query by a factor of 4.
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/Query.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java
index 5746bce3b9f..b0023260f67 100644
--- a/container-search/src/main/java/com/yahoo/search/Query.java
+++ b/container-search/src/main/java/com/yahoo/search/Query.java
@@ -426,28 +426,36 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
* dependent objects for the appropriate subset of the given property values
*/
private void setFieldsFrom(Properties properties, Map<String, String> context) {
- setFrom(CompoundName.empty, properties, Query.getArgumentType(), context);
+ setFrom("", properties, Query.getArgumentType(), context);
+ }
+
+ private static String append(String a, String b) {
+ if (a.isEmpty()) return b;
+ if (b.isEmpty()) return a;
+ return a + "." + b;
}
/**
* For each field in the given query profile type, take the corresponding value from originalProperties
* (if any) set it to properties(), recursively.
*/
- private void setFrom(CompoundName prefix, Properties originalProperties, QueryProfileType arguments, Map<String, String> context) {
- prefix = prefix.append(getPrefix(arguments));
+ private void setFrom(String prefix, Properties originalProperties, QueryProfileType arguments, Map<String, String> context) {
+ prefix = append(prefix, getPrefix(arguments).toString());
for (FieldDescription field : arguments.fields().values()) {
if (field.getType() == FieldType.genericQueryProfileType) { // Generic map
- CompoundName fullName = prefix.append(field.getCompoundName());
- for (Map.Entry<String, Object> entry : originalProperties.listProperties(fullName, context).entrySet()) {
- properties().set(fullName.append(entry.getKey()), entry.getValue(), context);
+ String fullName = append(prefix, field.getCompoundName().toString());
+ for (Map.Entry<String, Object> entry : originalProperties.listProperties(CompoundName.of(fullName), context).entrySet()) {
+ properties().set(CompoundName.of(append(fullName, entry.getKey())), entry.getValue(), context);
}
}
else if (field.getType() instanceof QueryProfileFieldType) { // Nested arguments
setFrom(prefix, originalProperties, ((QueryProfileFieldType)field.getType()).getQueryProfileType(), context);
}
else {
- CompoundName fullName = prefix.append(field.getCompoundName());
+ CompoundName fullName = prefix.isEmpty()
+ ? field.getCompoundName()
+ : CompoundName.of(append(prefix, field.getCompoundName().toString()));
Object value = originalProperties.get(fullName, context);
if (value != null) {
properties().set(fullName, value, context);