diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-08-17 08:24:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-17 08:24:27 +0200 |
commit | ecf3f1cfbd977e924e7152e72b46bf45054300be (patch) | |
tree | fa68e3b75233b3178f7787351adf6ca702b9631f /config-model/src/main/java/com/yahoo/searchdefinition | |
parent | 08c2567e0d63a9cffbd18713f5c2b31cf9cf7366 (diff) | |
parent | acec3af18f52b1713f9231a32a2203ebd6910f1c (diff) |
Merge pull request #18761 from vespa-engine/balder/wire-in-fileregistry-to-rankingconstants-and-onnxmodels
Wire in fileregistry to RankingConstants and OnnxModels.
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition')
6 files changed, 25 insertions, 14 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java b/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java index 60733a4f5ba..96ee8c0c2f4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java @@ -1,6 +1,7 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.application.api.FileRegistry; import com.yahoo.vespa.model.AbstractService; import java.util.Collection; @@ -16,7 +17,11 @@ import java.util.Map; public class OnnxModels { private final Map<String, OnnxModel> models = new HashMap<>(); + private final FileRegistry fileRegistry; + public OnnxModels(FileRegistry fileRegistry) { + this.fileRegistry = fileRegistry; + } public void add(OnnxModel model) { model.validate(); String name = model.getName(); 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 68e03ecb188..3c1f00f1252 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -120,9 +120,6 @@ public class RankProfile implements Cloneable { private List<ImmutableSDField> allFieldsList; - /** Global onnx models not tied to a search definition */ - private OnnxModels onnxModels = new OnnxModels(); - /** * Creates a new rank profile for a particular search definition * @@ -144,12 +141,11 @@ public class RankProfile implements Cloneable { * @param name the name of the new profile * @param model the model owning this profile */ - public RankProfile(String name, VespaModel model, RankProfileRegistry rankProfileRegistry, OnnxModels onnxModels) { + public RankProfile(String name, VespaModel model, RankProfileRegistry rankProfileRegistry) { this.name = Objects.requireNonNull(name, "name cannot be null"); this.search = null; this.model = Objects.requireNonNull(model, "model cannot be null"); this.rankProfileRegistry = rankProfileRegistry; - this.onnxModels = onnxModels; } public String getName() { return name; } @@ -168,7 +164,7 @@ public class RankProfile implements Cloneable { } public Map<String, OnnxModel> onnxModels() { - return search != null ? search.onnxModels().asMap() : onnxModels.asMap(); + return search != null ? search.onnxModels().asMap() : model.onnxModels().asMap(); } private Stream<ImmutableSDField> allFields() { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java index 82381aa63fc..a61e1ae3efb 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java @@ -1,6 +1,7 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.application.api.FileRegistry; import com.yahoo.vespa.model.AbstractService; import java.util.Collection; @@ -17,6 +18,11 @@ import java.util.Map; public class RankingConstants { private final Map<String, RankingConstant> constants = new HashMap<>(); + private final FileRegistry fileRegistry; + + public RankingConstants(FileRegistry fileRegistry) { + this.fileRegistry = fileRegistry; + } public void add(RankingConstant constant) { constant.validate(); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java index 973ac6655cc..f3d6e2f78a2 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java @@ -86,10 +86,10 @@ public class Search implements ImmutableSearch { private final LargeRankExpressions largeRankExpressions; /** Ranking constants of this */ - private final RankingConstants rankingConstants = new RankingConstants(); + private final RankingConstants rankingConstants; /** Onnx models of this */ - private final OnnxModels onnxModels = new OnnxModels(); + private final OnnxModels onnxModels; private Optional<TemporaryImportedFields> temporaryImportedFields = Optional.of(new TemporaryImportedFields()); private Optional<ImportedFields> importedFields = Optional.empty(); @@ -123,6 +123,8 @@ public class Search implements ImmutableSearch { this.properties = properties; this.documentsOnly = documentsOnly; largeRankExpressions = new LargeRankExpressions(fileRegistry); + rankingConstants = new RankingConstants(fileRegistry); + onnxModels = new OnnxModels(fileRegistry); } protected void setName(String name) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java index 52d99c523ea..16de8fd4b9e 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java @@ -85,8 +85,9 @@ public class DerivedConfiguration { summaries = new Summaries(search, deployLogger); summaryMap = new SummaryMap(search); juniperrc = new Juniperrc(search); - rankProfileList = new RankProfileList(search, search.rankingConstants(), search.rankExpressionFiles(), attributeFields, - rankProfileRegistry, queryProfiles, importedModels, deployProperties); + rankProfileList = new RankProfileList(search, search.rankingConstants(), search.rankExpressionFiles(), + search.onnxModels(), attributeFields, rankProfileRegistry, + queryProfiles, importedModels, deployProperties); indexingScript = new IndexingScript(search); indexInfo = new IndexInfo(search); indexSchema = new IndexSchema(search); 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 a9a04fccf5d..7f19fcd24d4 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 @@ -41,9 +41,9 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ public static RankProfileList empty = new RankProfileList(); private RankProfileList() { - rankingConstants = new RankingConstants(); - largeRankExpressions = new LargeRankExpressions(new MockFileRegistry()); - onnxModels = new OnnxModels(); + rankingConstants = new RankingConstants(null); + largeRankExpressions = new LargeRankExpressions(null); + onnxModels = new OnnxModels(null); dryRunOnnxOnSetup = true; } @@ -56,6 +56,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ public RankProfileList(Search search, RankingConstants rankingConstants, LargeRankExpressions largeRankExpressions, + OnnxModels onnxModels, AttributeFields attributeFields, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles, @@ -64,7 +65,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ setName(search == null ? "default" : search.getName()); this.rankingConstants = rankingConstants; this.largeRankExpressions = largeRankExpressions; - onnxModels = search == null ? new OnnxModels() : search.onnxModels(); // as ONNX models come from parsing rank expressions + this.onnxModels = onnxModels; // as ONNX models come from parsing rank expressions dryRunOnnxOnSetup = deployProperties.featureFlags().dryRunOnnxOnSetup(); deriveRankProfiles(rankProfileRegistry, queryProfiles, importedModels, search, attributeFields, deployProperties); } |