summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-05-13 09:44:30 +0200
committerJon Bratseth <bratseth@gmail.com>2022-05-13 09:44:30 +0200
commit1ac0e7b95b48ea75a1796856ea8e8ebac04f6b8d (patch)
treec82703cb1632fd5e2b82f8f038a54ccf41c3961c /config-model/src/main/java/com/yahoo/searchdefinition
parentefc33e32e7a3afe91d50b963a2adce00b799c223 (diff)
Validate constants in profiles
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java14
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java4
2 files changed, 9 insertions, 9 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 24f6b1390fd..95e022fca9e 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
@@ -412,10 +412,10 @@ public class RankProfile implements Cloneable {
}
/** Returns an unmodifiable view of the constants available in this */
- public Map<Reference, Constant> getConstants() {
+ public Map<Reference, Constant> constants() {
Map<Reference, Constant> allConstants = new HashMap<>();
for (var inheritedProfile : inherited()) {
- for (var constant : inheritedProfile.getConstants().values()) {
+ for (var constant : inheritedProfile.constants().values()) {
if (allConstants.containsKey(constant.name()))
throw new IllegalArgumentException(constant + "' is present in " +
inheritedProfile + " inherited by " +
@@ -935,7 +935,7 @@ public class RankProfile implements Cloneable {
}
private void compileThis(QueryProfileRegistry queryProfiles, ImportedMlModels importedModels) {
- checkNameCollisions(getFunctions(), getConstants());
+ checkNameCollisions(getFunctions(), constants());
ExpressionTransforms expressionTransforms = new ExpressionTransforms();
Map<Reference, TensorType> featureTypes = featureTypes();
@@ -943,8 +943,8 @@ public class RankProfile implements Cloneable {
Map<String, RankingExpressionFunction> inlineFunctions =
compileFunctions(this::getInlineFunctions, queryProfiles, featureTypes, importedModels, Collections.emptyMap(), expressionTransforms);
- firstPhaseRanking = compile(this.getFirstPhase(), queryProfiles, featureTypes, importedModels, getConstants(), inlineFunctions, expressionTransforms);
- secondPhaseRanking = compile(this.getSecondPhase(), queryProfiles, featureTypes, importedModels, getConstants(), inlineFunctions, expressionTransforms);
+ firstPhaseRanking = compile(this.getFirstPhase(), queryProfiles, featureTypes, importedModels, constants(), inlineFunctions, expressionTransforms);
+ secondPhaseRanking = compile(this.getSecondPhase(), queryProfiles, featureTypes, importedModels, constants(), inlineFunctions, expressionTransforms);
// Function compiling second pass: compile all functions and insert previously compiled inline functions
// TODO: This merges all functions from inherited profiles too and erases inheritance information. Not good.
@@ -979,7 +979,7 @@ public class RankProfile implements Cloneable {
while (null != (entry = findUncompiledFunction(functions.get(), compiledFunctions.keySet()))) {
RankingExpressionFunction rankingExpressionFunction = entry.getValue();
RankingExpressionFunction compiled = compile(rankingExpressionFunction, queryProfiles, featureTypes,
- importedModels, getConstants(), inlineFunctions,
+ importedModels, constants(), inlineFunctions,
expressionTransforms);
compiledFunctions.put(entry.getKey(), compiled);
}
@@ -1039,7 +1039,7 @@ public class RankProfile implements Cloneable {
Map<Reference, TensorType> featureTypes) {
MapEvaluationTypeContext context = new MapEvaluationTypeContext(getExpressionFunctions(), featureTypes);
- getConstants().forEach((k, v) -> context.setType(k, v.type()));
+ constants().forEach((k, v) -> context.setType(k, v.type()));
// Add query features from all rank profile types
for (QueryProfileType queryProfileType : queryProfiles.getTypeRegistry().allComponents()) {
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 f9c1f76a35d..770ca358ea4 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
@@ -76,9 +76,9 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
Map<Reference, RankProfile.Constant> allFileConstants = new HashMap<>();
addFileConstants(constantsFromSchema.values(), allFileConstants, schema != null ? schema.toString() : "[global]");
for (var profile : deployState.rankProfileRegistry().rankProfilesOf(schema))
- addFileConstants(profile.getConstants().values(), allFileConstants, profile.toString());
+ addFileConstants(profile.constants().values(), allFileConstants, profile.toString());
for (var profile : deployState.rankProfileRegistry().rankProfilesOf(null))
- addFileConstants(profile.getConstants().values(), allFileConstants, profile.toString());
+ addFileConstants(profile.constants().values(), allFileConstants, profile.toString());
return new FileDistributedConstants(deployState.getFileRegistry(), allFileConstants.values());
}