summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorLester Solbakken <lesters@oath.com>2021-01-07 14:32:45 +0100
committerLester Solbakken <lesters@oath.com>2021-01-07 14:32:45 +0100
commitd4ab3f6f55ba33bf4095158521493451a1828d65 (patch)
tree56e8a7f0c2a3bd5f4b4fbed62ab98aa27b50c68f /config-model
parentf064d4c32d0b80bc72b60d708a27201281cceac9 (diff)
Revert "Allow expressions as arguments"
This reverts commit 3578f2b70312e681b11db97e6ead8997e2dd7d3c.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionFeatureArgumentsTestCase.java108
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java14
2 files changed, 8 insertions, 114 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionFeatureArgumentsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionFeatureArgumentsTestCase.java
deleted file mode 100644
index 14228968161..00000000000
--- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionFeatureArgumentsTestCase.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.searchdefinition;
-
-import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
-import com.yahoo.collections.Pair;
-import com.yahoo.search.query.profile.QueryProfileRegistry;
-import com.yahoo.searchdefinition.derived.AttributeFields;
-import com.yahoo.searchdefinition.derived.RawRankProfile;
-import com.yahoo.searchdefinition.parser.ParseException;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author lesters
- */
-public class RankingExpressionFeatureArgumentsTestCase extends SchemaTestCase {
-
- @Test
- public void testFeatureWithExpressionArguments() throws ParseException {
- RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
- builder.importString(
- "search test {\n" +
- " document test { \n" +
- " field t1 type tensor<float>(x{}) { \n" +
- " indexing: attribute | summary \n" +
- " }\n" +
- " field t2 type tensor<float>(x{}) { \n" +
- " indexing: attribute | summary \n" +
- " }\n" +
- " }\n" +
- " rank-profile test {\n" +
- " function my_func(t) {\n" +
- " expression: sum(t, x) \n" +
- " }\n" +
- " function eval_func() {\n" +
- " expression: my_func( attribute(t1) ) \n" +
- " }\n" +
- " function eval_func_with_expr() {\n" +
- " expression: my_func( attribute(t1) * attribute(t2) ) \n" +
- " }\n" +
- " function eval_func_with_expr_2() {\n" +
- " expression: my_func( attribute(t1){x:0} ) \n" +
- " }\n" +
- " function eval_func_via_func_with_expr() {\n" +
- " expression: call_func_with_expr( attribute(t1), attribute(t2) ) \n" +
- " }\n" +
- " function call_func_with_expr(a, b) {\n" +
- " expression: my_func( a * b ) \n" +
- " }\n" +
- " first-phase {\n" +
- " expression: 42 \n" +
- " }\n" +
- " }\n" +
- "\n" +
- "}\n");
- builder.build();
- Search s = builder.getSearch();
- RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels());
- List<Pair<String, String>> testRankProperties = new RawRankProfile(test,
- new QueryProfileRegistry(),
- new ImportedMlModels(),
- new AttributeFields(s)).configProperties();
-
- for(Pair<String,String> prop : testRankProperties) {
- System.out.println(prop);
- }
-
- assertEquals("(rankingExpression(my_func).rankingScript, reduce(t, sum, x))",
- testRankProperties.get(0).toString());
-
- // eval_func
- assertEquals("(rankingExpression(eval_func).rankingScript, rankingExpression(my_func@9bbaee2bad5a2fc0))",
- testRankProperties.get(2).toString());
- assertEquals("(rankingExpression(my_func@9bbaee2bad5a2fc0).rankingScript, reduce(attribute(t1), sum, x))",
- testRankProperties.get(1).toString());
-
- // The following functions should generate features to evaluate the expression argument before passing to my_func
-
- // eval_func_with_expr
- assertEquals("(rankingExpression(eval_func_with_expr).rankingScript, rankingExpression(my_func@45673ba956ae9b77))",
- testRankProperties.get(5).toString());
- assertEquals("(rankingExpression(my_func@45673ba956ae9b77).rankingScript, reduce(autogenerated_ranking_feature@43bc412603c00a4a, sum, x))",
- testRankProperties.get(4).toString());
- assertEquals("(rankingExpression(autogenerated_ranking_feature@43bc412603c00a4a).rankingScript, attribute(t1) * attribute(t2))",
- testRankProperties.get(3).toString());
-
- // eval_func_with_expr_2
- assertEquals("(rankingExpression(eval_func_with_expr_2).rankingScript, rankingExpression(my_func@2192533eaad2293d))",
- testRankProperties.get(8).toString());
- assertEquals("(rankingExpression(my_func@2192533eaad2293d).rankingScript, reduce(autogenerated_ranking_feature@71a4196136b577cf, sum, x))",
- testRankProperties.get(7).toString());
- assertEquals("(rankingExpression(autogenerated_ranking_feature@71a4196136b577cf).rankingScript, attribute(t1){x:0})",
- testRankProperties.get(6).toString());
-
- // eval_func_via_func_with_expr
- assertEquals("(rankingExpression(eval_func_via_func_with_expr).rankingScript, rankingExpression(call_func_with_expr@640470df47a83000.c156faa8f98c0b0c))",
- testRankProperties.get(10).toString());
- assertEquals("(rankingExpression(call_func_with_expr@640470df47a83000.c156faa8f98c0b0c).rankingScript, rankingExpression(my_func@45673ba956ae9b77))",
- testRankProperties.get(9).toString());
- // my_func@45673ba956ae9b77 is the same as under eval_func_with_expr
-
- }
-
-} \ No newline at end of file
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java
index 20182c89a8c..84a6d2a154a 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java
@@ -207,20 +207,22 @@ public class RankingExpressionShadowingTestCase extends SchemaTestCase {
queryProfiles,
new ImportedMlModels(),
new AttributeFields(s)).configProperties();
- assertEquals("(rankingExpression(autogenerated_ranking_feature@).rankingScript, reduce(query(q) * constant(W_hidden), sum, input) + constant(b_input))",
+ assertEquals("(rankingExpression(relu@).rankingScript, max(1.0,reduce(query(q) * constant(W_hidden), sum, input) + constant(b_input)))",
censorBindingHash(testRankProperties.get(0).toString()));
- assertEquals("(rankingExpression(relu@).rankingScript, max(1.0,autogenerated_ranking_feature@))",
- censorBindingHash(testRankProperties.get(1).toString()));
assertEquals("(rankingExpression(hidden_layer).rankingScript, rankingExpression(relu@))",
+ censorBindingHash(testRankProperties.get(1).toString()));
+ assertEquals("(rankingExpression(hidden_layer).type, tensor(x[1]))",
censorBindingHash(testRankProperties.get(2).toString()));
assertEquals("(rankingExpression(final_layer).rankingScript, sigmoid(reduce(rankingExpression(hidden_layer) * constant(W_final), sum, hidden) + constant(b_final)))",
+ testRankProperties.get(3).toString());
+ assertEquals("(rankingExpression(final_layer).type, tensor(x[1]))",
testRankProperties.get(4).toString());
assertEquals("(rankingExpression(relu).rankingScript, max(1.0,x))",
- testRankProperties.get(6).toString());
+ testRankProperties.get(5).toString());
assertEquals("(vespa.rank.secondphase, rankingExpression(secondphase))",
- testRankProperties.get(7).toString());
+ testRankProperties.get(6).toString());
assertEquals("(rankingExpression(secondphase).rankingScript, reduce(rankingExpression(final_layer), sum))",
- testRankProperties.get(8).toString());
+ testRankProperties.get(7).toString());
}
private QueryProfileRegistry queryProfileWith(String field, String type) {