diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-03-07 11:31:08 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-03-07 11:31:08 +0000 |
commit | 685391324e5fffc450e8022ce39569b5e584e3d0 (patch) | |
tree | b2a6b7a2f89ebf0f4af4186e9695b8d07de1905a /config-model/src | |
parent | 6d4608361bfbb12cee3e0905d8e6763605ce7abf (diff) |
call addFunctionTypeSerialization in more cases
Diffstat (limited to 'config-model/src')
3 files changed, 12 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()); diff --git a/config-model/src/test/derived/rankingexpression/rank-profiles.cfg b/config-model/src/test/derived/rankingexpression/rank-profiles.cfg index e3947e9e46f..202669ae049 100644 --- a/config-model/src/test/derived/rankingexpression/rank-profiles.cfg +++ b/config-model/src/test/derived/rankingexpression/rank-profiles.cfg @@ -351,6 +351,8 @@ rankprofile[].fef.property[].name "rankingExpression(myplus).rankingScript" rankprofile[].fef.property[].value "attribute(foo1) + attribute(foo2)" rankprofile[].fef.property[].name "rankingExpression(mymul).rankingScript" rankprofile[].fef.property[].value "attribute(t1) * query(fromq)" +rankprofile[].fef.property[].name "rankingExpression(mymul).type" +rankprofile[].fef.property[].value "tensor(m{},v[3])" rankprofile[].fef.property[].name "vespa.rank.firstphase" rankprofile[].fef.property[].value "attribute(foo1)" rankprofile[].fef.property[].name "vespa.rank.secondphase" diff --git a/config-model/src/test/derived/renamedfeatures/rank-profiles.cfg b/config-model/src/test/derived/renamedfeatures/rank-profiles.cfg index d084401d920..ea2d051484b 100644 --- a/config-model/src/test/derived/renamedfeatures/rank-profiles.cfg +++ b/config-model/src/test/derived/renamedfeatures/rank-profiles.cfg @@ -56,6 +56,8 @@ rankprofile[].fef.property[].value "tensor(m{},v[3])" rankprofile[].name "withmf" rankprofile[].fef.property[].name "rankingExpression(mymul).rankingScript" rankprofile[].fef.property[].value "attribute(t1) * query(fromq)" +rankprofile[].fef.property[].name "rankingExpression(mymul).type" +rankprofile[].fef.property[].value "tensor(m{},v[3])" rankprofile[].fef.property[].name "rankingExpression(myplus).rankingScript" rankprofile[].fef.property[].value "attribute(foo1) + attribute(foo2)" rankprofile[].fef.property[].name "vespa.rank.firstphase" |