aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-10-30 16:31:38 +0200
committerGitHub <noreply@github.com>2021-10-30 16:31:38 +0200
commit1da6754a571bb380cc32d77b7aa76fe5ebaa24b0 (patch)
tree127022f9f9fe999f2db5666312d19d2be39ece82 /container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
parentd8970d73872e5386f36aaa73e2dc6b0e881069bf (diff)
parentc702f4874ea9f0cb263a3e54471eef5bb1c71d8c (diff)
Merge pull request #19792 from vespa-engine/bratseth/stable-query-profile-idsv7.492.78
Bratseth/stable query profile ids
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
index ee7d44f457f..c30a78da57d 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
@@ -45,6 +45,9 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
/** The name of the source of this (a file) */
private final String source;
+ /** The query profile registry owning this, or null if none (which will only happen in tests) */
+ public final QueryProfileRegistry owner;
+
/** Defines the permissible content of this, or null if any content is permissible */
private QueryProfileType type = null;
@@ -84,8 +87,13 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
}
public QueryProfile(ComponentId id, String sourceName) {
+ this(id, sourceName, null);
+ }
+
+ public QueryProfile(ComponentId id, String sourceName, QueryProfileRegistry owner) {
super(id);
this.source = sourceName;
+ this.owner = owner;
if ( ! id.isAnonymous())
validateName(id.getName());
}
@@ -96,6 +104,8 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
public String getSource() { return source; }
+ protected final QueryProfileRegistry getOwner() { return owner; }
+
/** Returns the type of this or null if it has no type */
public QueryProfileType getType() { return type; }
@@ -144,6 +154,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
/**
* Returns the content fields declared in this (i.e not including those inherited) as a read-only map.
+ *
* @throws IllegalStateException if this is frozen
*/
public Map<String, Object> declaredContent() {
@@ -390,7 +401,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
* Switches this from write-only to read-only mode.
* This profile can never be modified again after this method returns.
* Calling this on an already frozen profile has no effect.
- * <p>
+ *
* Calling this will also freeze any profiles inherited and referenced by this.
*/
// TODO: Remove/simplify as query profiles are not used at query time
@@ -624,7 +635,8 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
QueryProfile newProfile = (QueryProfile)newValue;
if ( ! (existingValue instanceof QueryProfile)) {
if ( ! isModifiable(newProfile)) {
- newProfile = new BackedOverridableQueryProfile(newProfile); // Make the query profile reference overridable
+ // Make the query profile reference overridable
+ newProfile = new BackedOverridableQueryProfile(newProfile);
}
newProfile.value = existingValue;
return newProfile;
@@ -652,7 +664,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
}
}
- private static QueryProfile combineProfiles(QueryProfile newProfile,QueryProfile existingProfile) {
+ private static QueryProfile combineProfiles(QueryProfile newProfile, QueryProfile existingProfile) {
QueryProfile returnValue = null;
QueryProfile existingModifiable;
@@ -720,7 +732,8 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
* This default implementation returns an empty profile.
*/
protected QueryProfile createSubProfile(String name, DimensionBinding dimensionBinding) {
- return new QueryProfile(ComponentId.createAnonymousComponentId(name), source);
+ var id = owner != null ? owner.createAnonymousId(name) : ComponentId.createAnonymousComponentId(name);
+ return new QueryProfile(id, source, owner);
}
/** Do a variant-aware content lookup in this */