aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-06-24 13:08:17 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2022-06-24 13:08:17 +0200
commit38949af230d96bbda6adb6da1e336275e78e41e9 (patch)
treefc716a07be3474e8571847e5ca4f28764eff6798 /container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
parentacd3b9c6149538dcb42970a4d358cb2a26294c15 (diff)
Precompute a zone context to avoid always having to compute them on the fly.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
index 8c1a0ac1d25..5a12eeddd17 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
@@ -34,6 +34,7 @@ public class QueryProfileProperties extends Properties {
private final CompiledQueryProfile profile;
private final Map<String, Embedder> embedders;
private final ZoneInfo zoneInfo;
+ private final Map<String, String> zoneContext;
// Note: The priority order is: values has precedence over references
@@ -68,6 +69,11 @@ public class QueryProfileProperties extends Properties {
this.profile = profile;
this.embedders = embedders;
this.zoneInfo = zoneInfo;
+ this.zoneContext = Map.of(
+ "environment", zoneInfo.zone().environment().name(),
+ "region", zoneInfo.zone().region(),
+ "instance", zoneInfo.application().instance());
+
}
/** Returns the query profile backing this, or null if none */
@@ -289,8 +295,10 @@ public class QueryProfileProperties extends Properties {
private Map<String, String> contextWithZoneInfo(Map<String, String> context) {
if (zoneInfo == ZoneInfo.defaultInfo()) return context;
+ if (context == null) return zoneContext;
+ if (context == zoneContext) return context;
- Map<String, String> contextWithZoneInfo = context == null ? new HashMap<>() : new HashMap<>(context);
+ Map<String, String> contextWithZoneInfo = new HashMap<>(context);
contextWithZoneInfo.putIfAbsent("environment", zoneInfo.zone().environment().name());
contextWithZoneInfo.putIfAbsent("region", zoneInfo.zone().region());
contextWithZoneInfo.putIfAbsent("instance", zoneInfo.application().instance());