summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-09-17 14:00:36 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2021-09-17 14:00:36 +0200
commitc899214332081ed88c4c2d32ae13a408241a4649 (patch)
tree8edf6e651fa1f8a06a1da372a51aef661062243a /config-model/src/main/java/com/yahoo
parent8ea41e9c017b4f28ea49ec94eaef70b0aa0990ec (diff)
Process rank-profiles in dependency order.
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java43
1 files changed, 35 insertions, 8 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
index 122c39f440f..461b9109dfa 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
@@ -20,6 +20,8 @@ import com.yahoo.vespa.model.AbstractService;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
@@ -72,6 +74,12 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
deriveRankProfiles(rankProfileRegistry, queryProfiles, importedModels, search, attributeFields, deployProperties, executor);
}
+ private boolean areDependenciesReady(RankProfile rank, RankProfileRegistry registry) {
+ return (rank.getInheritedName() == null) ||
+ rankProfiles.containsKey(rank.getInheritedName()) ||
+ (rank.getSearch() != null && registry.resolve(rank.getSearch().getDocument(), rank.getInheritedName()) != null);
+ }
+
private void deriveRankProfiles(RankProfileRegistry rankProfileRegistry,
QueryProfileRegistry queryProfiles,
ImportedMlModels importedModels,
@@ -79,23 +87,42 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
AttributeFields attributeFields,
ModelContext.Properties deployProperties,
ExecutorService executor) {
- List<Future<RawRankProfile>> futureRawRankProfiles = new ArrayList<>();
if (search != null) { // profiles belonging to a search have a default profile
- futureRawRankProfiles.add(executor.submit(() -> new RawRankProfile(rankProfileRegistry.get(search, "default"),
- largeRankExpressions, queryProfiles, importedModels, attributeFields, deployProperties)));
+ RawRankProfile rawRank = new RawRankProfile(rankProfileRegistry.get(search, "default"),
+ largeRankExpressions, queryProfiles, importedModels, attributeFields, deployProperties);
+ rankProfiles.put(rawRank.getName(), rawRank);
}
- for (RankProfile rank : rankProfileRegistry.rankProfilesOf(search)) {
- if (search != null && "default".equals(rank.getName())) continue;
+ Map<String, RankProfile> remaining = new LinkedHashMap<>();
+ rankProfileRegistry.rankProfilesOf(search).forEach(rank -> remaining.put(rank.getName(), rank));
+ remaining.remove("default");
+ while (!remaining.isEmpty()) {
+ List<RankProfile> ready = new ArrayList<>();
+ remaining.forEach((name, rank) -> {
+ if (areDependenciesReady(rank, rankProfileRegistry)) ready.add(rank);
+ });
+ processRankProfiles(ready, queryProfiles, importedModels, search, attributeFields, deployProperties, executor);
+ ready.forEach(rank -> remaining.remove(rank.getName()));
+ }
+ }
+ private void processRankProfiles(List<RankProfile> ready,
+ QueryProfileRegistry queryProfiles,
+ ImportedMlModels importedModels,
+ Search search,
+ AttributeFields attributeFields,
+ ModelContext.Properties deployProperties,
+ ExecutorService executor) {
+ Map<String, Future<RawRankProfile>> futureRawRankProfiles = new LinkedHashMap<>();
+ for (RankProfile rank : ready) {
if (search == null) {
- this.onnxModels.add(rank.onnxModels());
+ onnxModels.add(rank.onnxModels());
}
- futureRawRankProfiles.add(executor.submit(() -> new RawRankProfile(rank, largeRankExpressions, queryProfiles, importedModels,
+ futureRawRankProfiles.put(rank.getName(), executor.submit(() -> new RawRankProfile(rank, largeRankExpressions, queryProfiles, importedModels,
attributeFields, deployProperties)));
}
try {
- for (Future<RawRankProfile> rawFuture : futureRawRankProfiles) {
+ for (Future<RawRankProfile> rawFuture : futureRawRankProfiles.values()) {
RawRankProfile rawRank = rawFuture.get();
rankProfiles.put(rawRank.getName(), rawRank);
}