diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-02-01 17:13:47 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-02-01 17:13:47 +0100 |
commit | d492c5c573a561bc67a8bd0478d94e616817eaeb (patch) | |
tree | 714b2a29e95cdcf8a94e95e1a04db73aa9062e1f /config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java | |
parent | 58a80a9ea9dafd36a8d9f204725bfced2e0dbcad (diff) |
Resolve once, after each change
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index 53e9cfd5601..5b842b002bd 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -205,25 +205,22 @@ public class RankProfile implements Cloneable { * The profile must belong to this schema (directly or by inheritance). */ public void inherit(String inheritedName) { + inherited = null; inheritedNames.add(inheritedName); } /** Returns the names of the profiles this inherits, if any. */ - public List<String> inheritedNames() { return inheritedNames; } + public List<String> inheritedNames() { return Collections.unmodifiableList(inheritedNames); } /** Returns the rank profiles inherited by this. */ private List<RankProfile> inherited() { if (inheritedNames.isEmpty()) return List.of(); if (inherited != null) return inherited; - for (String inheritedName : inheritedNames) { - inherited = (schema() != null) ? resolveInheritedProfiles(schema) - : List.of(rankProfileRegistry.getGlobal(inheritedName)); - - List<String> children = new ArrayList<>(); - children.add(createFullyQualifiedName()); - inherited.forEach(profile -> verifyNoInheritanceCycle(children, profile)); - } + inherited = resolveInheritedProfiles(schema); + List<String> children = new ArrayList<>(); + children.add(createFullyQualifiedName()); + inherited.forEach(profile -> verifyNoInheritanceCycle(children, profile)); return inherited; } @@ -245,7 +242,9 @@ public class RankProfile implements Cloneable { private List<RankProfile> resolveInheritedProfiles(ImmutableSchema schema) { List<RankProfile> inherited = new ArrayList<>(); for (String inheritedName : inheritedNames) { - RankProfile inheritedProfile = resolveInheritedProfile(schema, inheritedName); + RankProfile inheritedProfile = schema == null + ? rankProfileRegistry.getGlobal(inheritedName) + : resolveInheritedProfile(schema, inheritedName); if (inheritedProfile == null) throw new IllegalArgumentException("rank-profile '" + name() + "' inherits '" + inheritedName + "', but this is not found in " + |