summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2020-02-12 15:10:46 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2020-02-12 15:10:46 +0100
commit20a95cc0bc4fe4f1e719b6a1338cf3dd7429406f (patch)
tree41bd061afe405c093a4f95fd0a95770ecaf18024 /container-search
parentc9ff9b55b4bd30e5492af18c1b5190316ca2deee (diff)
Also extend inherited types
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
index e3696916c53..d6faa6097f9 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
@@ -24,9 +24,8 @@ import static com.yahoo.text.Lowercase.toLowerCase;
*/
public class QueryProfileType extends FreezableSimpleComponent {
- private static final String simpleClassName = QueryProfileType.class.getSimpleName();
-
private final CompoundName componentIdAsCompoundName;
+
/** The fields of this query profile type */
private Map<String, FieldDescription> fields;
@@ -307,6 +306,7 @@ public class QueryProfileType extends FreezableSimpleComponent {
private QueryProfileType extendOrCreateQueryProfileType(String name, QueryProfileTypeRegistry registry) {
QueryProfileType type = null;
FieldDescription fieldDescription = getField(name);
+ System.out.println("Extending/creating " + name + ". Description: " + fieldDescription + " (is frozen " + isFrozen() + ")");
if (fieldDescription != null) {
if ( ! (fieldDescription.getType() instanceof QueryProfileFieldType))
throw new IllegalArgumentException("Cannot use name '" + name + "' as a prefix because it is " +
@@ -317,11 +317,13 @@ public class QueryProfileType extends FreezableSimpleComponent {
if (type == null) {
type = registry.getComponent(name);
- if (type != null) { // found in registry but not already added in this type: extend it
- type = new QueryProfileType(ComponentId.createAnonymousComponentId(type.getIdString()),
- new HashMap<>(),
- List.of(type));
- }
+ }
+
+ // found in registry but not already added in *this* type (getField also checks parents): extend it
+ if (type != null && ! fields.containsKey(name)) {
+ type = new QueryProfileType(ComponentId.createAnonymousComponentId(type.getIdString()),
+ new HashMap<>(),
+ List.of(type));
}
if (type == null) { // create it