diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-05-11 13:33:45 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-05-11 13:33:45 +0000 |
commit | 188de4702809b4bb8180c9d7045559e3eae5c8fe (patch) | |
tree | a80d9dd228c78858a2115eedfb44b823b502cfa9 /config-model/src/test/java/com | |
parent | 737e1e172389288bd28b3286d49601a60e306bb8 (diff) |
also add rank properties for "constant(foo)"
* ConstantTensorTransformer was trying to handle both "foo" and "constant(foo)",
but the latter would lookup "constant" not "foo" in the map.
* add unit test for this variation also.
Diffstat (limited to 'config-model/src/test/java/com')
-rw-r--r-- | config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java index a1231a1418b..10ba6eff169 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java @@ -33,6 +33,26 @@ public class RankingExpressionWithTensorTestCase { } @Test + public void requireConstantTensorCanBeReferredViaConstantFeature() throws ParseException { + RankProfileSearchFixture f = new RankProfileSearchFixture( + " rank-profile my_profile {\n" + + " first-phase {\n" + + " expression: sum(constant(my_tensor))\n" + + " }\n" + + " constants {\n" + + " my_tensor {\n" + + " value: { {x:1,y:2}:1, {x:2,y:1}:2 }\n" + + " type: tensor(x{},y{})\n" + + " }\n" + + " }\n" + + " }"); + f.compileRankProfile("my_profile"); + f.assertFirstPhaseExpression("reduce(constant(my_tensor), sum)", "my_profile"); + f.assertRankProperty("tensor(x{},y{}):{{x:1,y:2}:1.0,{x:2,y:1}:2.0}", "constant(my_tensor).value", "my_profile"); + f.assertRankProperty("tensor(x{},y{})", "constant(my_tensor).type", "my_profile"); + } + + @Test public void requireThatMultiLineConstantTensorAndTypeCanBeParsed() throws ParseException { RankProfileSearchFixture f = new RankProfileSearchFixture( " rank-profile my_profile {\n" + |