summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-05-18 11:38:27 +0200
committerJon Bratseth <bratseth@gmail.com>2022-05-18 11:38:27 +0200
commit619d924440939076e399f2504fa6850976d2a303 (patch)
tree83d680e0c0c516585b6d4e8e086d825dcb381365 /config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java
parent16de8d32fd0394335ffa065b61f4943c4fd49542 (diff)
Unify constant syntax across models and rank profiles
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java36
1 files changed, 35 insertions, 1 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 114486a5ddc..5bf2115c3f7 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
@@ -13,7 +13,7 @@ import static org.junit.Assert.fail;
public class RankingExpressionWithTensorTestCase {
@Test
- public void requireThatSingleLineConstantTensorAndTypeCanBeParsed() throws ParseException {
+ public void requireThatSingleLineConstantMappedTensorCanBeParsed() throws ParseException {
RankProfileSearchFixture f = new RankProfileSearchFixture(
" rank-profile my_profile {\n" +
" first-phase {\n" +
@@ -30,6 +30,40 @@ public class RankingExpressionWithTensorTestCase {
}
@Test
+ public void requireThatSingleLineConstantIndexedTensorCanBeParsed() throws ParseException {
+ RankProfileSearchFixture f = new RankProfileSearchFixture(
+ " rank-profile my_profile {\n" +
+ " first-phase {\n" +
+ " expression: sum(my_tensor)\n" +
+ " }\n" +
+ " constants {\n" +
+ " my_tensor tensor(x[3]):{ {x:0}:1, {x:1}:2, {x:2}:3 }\n" +
+ " }\n" +
+ " }");
+ f.compileRankProfile("my_profile");
+ f.assertFirstPhaseExpression("reduce(constant(my_tensor), sum)", "my_profile");
+ f.assertRankProperty("tensor(x[3]):[1.0, 2.0, 3.0]", "constant(my_tensor).value", "my_profile");
+ f.assertRankProperty("tensor(x[3])", "constant(my_tensor).type", "my_profile");
+ }
+
+ @Test
+ public void requireThatSingleLineConstantIndexedTensorShortFormCanBeParsed() throws ParseException {
+ RankProfileSearchFixture f = new RankProfileSearchFixture(
+ " rank-profile my_profile {\n" +
+ " first-phase {\n" +
+ " expression: sum(my_tensor)\n" +
+ " }\n" +
+ " constants {\n" +
+ " my_tensor tensor(x[3]):[1, 2, 3]\n" +
+ " }\n" +
+ " }");
+ f.compileRankProfile("my_profile");
+ f.assertFirstPhaseExpression("reduce(constant(my_tensor), sum)", "my_profile");
+ f.assertRankProperty("tensor(x[3]):[1.0, 2.0, 3.0]", "constant(my_tensor).value", "my_profile");
+ f.assertRankProperty("tensor(x[3])", "constant(my_tensor).type", "my_profile");
+ }
+
+ @Test
public void requireConstantTensorCanBeReferredViaConstantFeature() throws ParseException {
RankProfileSearchFixture f = new RankProfileSearchFixture(
" rank-profile my_profile {\n" +