aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-03-07 15:23:45 +0100
committerGitHub <noreply@github.com>2023-03-07 15:23:45 +0100
commit56057c40b54fc5b031ab9c2bfea9450e0ee77993 (patch)
tree956656920d38c4f508a19bfa5cd222c263ae9123 /config-model/src/main
parent0d569d1ba3661484b3d30c94dadae9d0444ffe98 (diff)
parent1197f63fe1a32b3e17493c9387527ac1c4e40cff (diff)
Merge pull request #26338 from vespa-engine/arnej/declare-more-function-return-types
Arnej/declare more function return types
Diffstat (limited to 'config-model/src/main')
-rw-r--r--config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java
index acb125197d2..6272563f833 100644
--- a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java
+++ b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java
@@ -248,15 +248,15 @@ public class RawRankProfile implements RankProfilesConfig.Producer {
SerializationContext context) {
for (Map.Entry<String, RankProfile.RankingExpressionFunction> e : functions.entrySet()) {
String propertyName = RankingExpression.propertyName(e.getKey());
- if (context.serializedFunctions().containsKey(propertyName)) continue;
+ if (! context.serializedFunctions().containsKey(propertyName)) {
- String expressionString = e.getValue().function().getBody().getRoot().toString(context).toString();
+ String expressionString = e.getValue().function().getBody().getRoot().toString(context).toString();
+ context.addFunctionSerialization(propertyName, expressionString);
+ e.getValue().function().argumentTypes().entrySet().stream().sorted(Map.Entry.comparingByKey())
+ .forEach(argumentType -> context.addArgumentTypeSerialization(e.getKey(), argumentType.getKey(), argumentType.getValue()));
+ }
+ e.getValue().function().returnType().ifPresent(t -> context.addFunctionTypeSerialization(e.getKey(), t));
- context.addFunctionSerialization(propertyName, expressionString);
- e.getValue().function().argumentTypes().entrySet().stream().sorted(Map.Entry.comparingByKey())
- .forEach(argumentType -> context.addArgumentTypeSerialization(e.getKey(), argumentType.getKey(), argumentType.getValue()));
- if (e.getValue().function().returnType().isPresent())
- context.addFunctionTypeSerialization(e.getKey(), e.getValue().function().returnType().get());
// else if (e.getValue().function().arguments().isEmpty()) TODO: Enable this check when we resolve all types
// throw new IllegalStateException("Type of function '" + e.getKey() + "' is not resolved");
}
@@ -274,6 +274,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer {
String propertyName = RankingExpression.propertyName(referenceNode.getName());
String expressionString = function.getBody().getRoot().toString(context).toString();
context.addFunctionSerialization(propertyName, expressionString);
+ function.returnType().ifPresent(t -> context.addFunctionTypeSerialization(referenceNode.getName(), t));
var backendReferenceNode = new ReferenceNode(wrapInRankingExpression(referenceNode.getName()),
referenceNode.getArguments().expressions(),
referenceNode.getOutput());