diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-24 14:19:27 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-24 14:19:27 +0200 |
commit | d2d5867ec560c192da03bf63326dfb0fb326643a (patch) | |
tree | bfbce7f9449d193ca029fde126f785a84e34ec4a /container-search | |
parent | aa244b000fe8ef9db2e8c8fea7921b7cd1a71d84 (diff) |
If it already has all keys there is no need to create a new hashmap.
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java | 10 |
1 files changed, 7 insertions, 3 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 5a12eeddd17..c821f22bc49 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 @@ -31,6 +31,9 @@ import java.util.Map; */ public class QueryProfileProperties extends Properties { + private static final String ENVIRONMENT = "environment"; + private static final String REGION = "region"; + private static final String INSTANCE = "instance"; private final CompiledQueryProfile profile; private final Map<String, Embedder> embedders; private final ZoneInfo zoneInfo; @@ -70,9 +73,9 @@ public class QueryProfileProperties extends Properties { this.embedders = embedders; this.zoneInfo = zoneInfo; this.zoneContext = Map.of( - "environment", zoneInfo.zone().environment().name(), - "region", zoneInfo.zone().region(), - "instance", zoneInfo.application().instance()); + ENVIRONMENT, zoneInfo.zone().environment().name(), + REGION, zoneInfo.zone().region(), + INSTANCE, zoneInfo.application().instance()); } @@ -297,6 +300,7 @@ public class QueryProfileProperties extends Properties { if (zoneInfo == ZoneInfo.defaultInfo()) return context; if (context == null) return zoneContext; if (context == zoneContext) return context; + if (context.containsKey(ENVIRONMENT) && context.containsKey(REGION) && context.containsKey(INSTANCE)) return context; Map<String, String> contextWithZoneInfo = new HashMap<>(context); contextWithZoneInfo.putIfAbsent("environment", zoneInfo.zone().environment().name()); |