aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2023-03-07 11:31:08 +0000
committerArne Juul <arnej@yahooinc.com>2023-03-07 11:31:08 +0000
commit685391324e5fffc450e8022ce39569b5e584e3d0 (patch)
treeb2a6b7a2f89ebf0f4af4186e9695b8d07de1905a /config-model/src/main/java/com
parent6d4608361bfbb12cee3e0905d8e6763605ce7abf (diff)
call addFunctionTypeSerialization in more cases
Diffstat (limited to 'config-model/src/main/java/com')
-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());