diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-03-20 11:26:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 11:26:26 +0100 |
commit | 47e7d6a7509c5ba3a339afbaa0f17b16d9b382af (patch) | |
tree | ad511fda70c2bdaffa21311ce3fb069cf95730b3 /config-model/src/test | |
parent | 89862f601ce193c1b8aa96d9979ad5ef57c1a505 (diff) | |
parent | 24b297f12cdb8707d15ad554554eaaff76bcbdd3 (diff) |
Merge branch 'master' into arnej/handle-dynamic-tensor
Diffstat (limited to 'config-model/src/test')
5 files changed, 144 insertions, 51 deletions
diff --git a/config-model/src/test/derived/rankproperties/rank-profiles.cfg b/config-model/src/test/derived/rankproperties/rank-profiles.cfg index 3ca44288282..b6f51a88197 100644 --- a/config-model/src/test/derived/rankproperties/rank-profiles.cfg +++ b/config-model/src/test/derived/rankproperties/rank-profiles.cfg @@ -50,3 +50,49 @@ rankprofile[].fef.property[].name "vespa.fieldweight.description" rankprofile[].fef.property[].value "35" rankprofile[].fef.property[].name "vespa.fieldweight.tag" rankprofile[].fef.property[].value "88" +rankprofile[].name "withconstants1" +rankprofile[].fef.property[].name "constant(a).value" +rankprofile[].fef.property[].value "tensor(x[2]):[1.0, 2.0]" +rankprofile[].fef.property[].name "constant(a).type" +rankprofile[].fef.property[].value "tensor(x[2])" +rankprofile[].fef.property[].name "constant(b).value" +rankprofile[].fef.property[].value "tensor(y[3]):[3.0, 4.0, 5.0]" +rankprofile[].fef.property[].name "constant(b).type" +rankprofile[].fef.property[].value "tensor(y[3])" +rankprofile[].fef.property[].name "rankingExpression(usea).rankingScript" +rankprofile[].fef.property[].value "constant(a) * 1.0" +rankprofile[].fef.property[].name "rankingExpression(usea).type" +rankprofile[].fef.property[].value "tensor(x[2])" +rankprofile[].fef.property[].name "rankingExpression(useb).rankingScript" +rankprofile[].fef.property[].value "constant(a) * 1.0 + constant(b)" +rankprofile[].fef.property[].name "rankingExpression(useb).type" +rankprofile[].fef.property[].value "tensor(x[2],y[3])" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "rankingExpression(firstphase)" +rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript" +rankprofile[].fef.property[].value "reduce(nativeFieldMatch + constant(a) * 1.0 + constant(b), sum)" +rankprofile[].name "withconstants2" +rankprofile[].fef.property[].name "constant(a).value" +rankprofile[].fef.property[].value "tensor(x[2]):[1.0, 2.0]" +rankprofile[].fef.property[].name "constant(a).type" +rankprofile[].fef.property[].value "tensor(x[2])" +rankprofile[].fef.property[].name "constant(b).value" +rankprofile[].fef.property[].value "tensor(y[3]):[3.0, 4.0, 5.0]" +rankprofile[].fef.property[].name "constant(b).type" +rankprofile[].fef.property[].value "tensor(y[3])" +rankprofile[].fef.property[].name "rankingExpression(usea).rankingScript" +rankprofile[].fef.property[].value "constant(a) * 1.0" +rankprofile[].fef.property[].name "rankingExpression(usea).type" +rankprofile[].fef.property[].value "tensor(x[2])" +rankprofile[].fef.property[].name "rankingExpression(useb).rankingScript" +rankprofile[].fef.property[].value "constant(a) * 1.0 + constant(b)" +rankprofile[].fef.property[].name "rankingExpression(useb).type" +rankprofile[].fef.property[].value "tensor(x[2],y[3])" +rankprofile[].fef.property[].name "rankingExpression(usec).rankingScript" +rankprofile[].fef.property[].value "constant(a) + constant(b)" +rankprofile[].fef.property[].name "rankingExpression(usec).type" +rankprofile[].fef.property[].value "tensor(x[2],y[3])" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "rankingExpression(firstphase)" +rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript" +rankprofile[].fef.property[].value "reduce(nativeFieldMatch + constant(a) + constant(b), sum)" diff --git a/config-model/src/test/derived/rankproperties/rankproperties.sd b/config-model/src/test/derived/rankproperties/rankproperties.sd index a2eb987d4ff..a13b3081ca7 100644 --- a/config-model/src/test/derived/rankproperties/rankproperties.sd +++ b/config-model/src/test/derived/rankproperties/rankproperties.sd @@ -59,4 +59,28 @@ schema rankproperties { } } + rank-profile withconstants1 { + constants { + constant(a) tensor(x[2]) : [1,2] + constant(b) tensor(y[3]) : [3,4,5] + } + function inline usea() { + expression: constant(a)*1.0 + } + function inline useb() { + expression: usea + constant(b) + } + first-phase { + expression: sum(nativeFieldMatch + useb) + } + } + + rank-profile withconstants2 inherits withconstants1 { + function inline usec() { + expression: constant(a)+constant(b) + } + first-phase { + expression: sum(nativeFieldMatch + usec) + } + } } diff --git a/config-model/src/test/java/com/yahoo/schema/processing/BoolAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/BoolAttributeValidatorTestCase.java deleted file mode 100644 index f19b1f43115..00000000000 --- a/config-model/src/test/java/com/yahoo/schema/processing/BoolAttributeValidatorTestCase.java +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.processing; - -import com.yahoo.schema.parser.ParseException; -import org.junit.jupiter.api.Test; - -import static com.yahoo.schema.ApplicationBuilder.createFromString; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static com.yahoo.config.model.test.TestUtil.joinLines; -import static org.junit.jupiter.api.Assertions.fail; - -/** - * @author geirst - */ -public class BoolAttributeValidatorTestCase { - - @Test - void array_of_bool_attribute_is_not_supported() throws ParseException { - try { - createFromString(getSd("field b type array<bool> { indexing: attribute }")); - fail("Expected exception"); - } - catch (IllegalArgumentException e) { - assertEquals("For schema 'test', field 'b': Only single value bool attribute fields are supported", - e.getMessage()); - } - } - - @Test - void weigtedset_of_bool_attribute_is_not_supported() throws ParseException { - try { - createFromString(getSd("field b type weightedset<bool> { indexing: attribute }")); - fail("Expected exception"); - } - catch (IllegalArgumentException e) { - assertEquals("For schema 'test', field 'b': Only single value bool attribute fields are supported", - e.getMessage()); - } - } - - private String getSd(String field) { - return joinLines( - "schema test {", - " document test {", - " " + field, - " }", - "}"); - } - -} diff --git a/config-model/src/test/java/com/yahoo/schema/processing/SingleValueOnlyAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/SingleValueOnlyAttributeValidatorTestCase.java new file mode 100644 index 00000000000..a7f4125a537 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/schema/processing/SingleValueOnlyAttributeValidatorTestCase.java @@ -0,0 +1,73 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.schema.processing; + +import com.yahoo.schema.parser.ParseException; +import org.junit.jupiter.api.Test; + +import static com.yahoo.schema.ApplicationBuilder.createFromString; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static com.yahoo.config.model.test.TestUtil.joinLines; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * @author geirst + */ +public class SingleValueOnlyAttributeValidatorTestCase { + + private static void array_attribute_is_not_supported(String type) throws ParseException { + try { + createFromString(getSd("field b type array<" + type + "> { indexing: attribute }")); + fail("Expected exception"); + } + catch (IllegalArgumentException e) { + assertEquals("For schema 'test', field 'b': Only single value " + type + " attribute fields are supported", + e.getMessage()); + } + } + + private static void weightedset_attribute_is_not_supported(String type) throws ParseException { + try { + createFromString(getSd("field b type weightedset<" + type + "> { indexing: attribute }")); + fail("Expected exception"); + } + catch (IllegalArgumentException e) { + if (type.equals("raw")) { + assertEquals("weightedset of complex type '[type BUILTIN] {raw}' is not supported", + e.getMessage()); + } else { + assertEquals("For schema 'test', field 'b': Only single value " + type + " attribute fields are supported", + e.getMessage()); + } + } + } + + @Test + void array_of_bool_attribute_is_not_supported() throws ParseException { + array_attribute_is_not_supported("bool"); + } + + @Test + void weightedset_of_bool_attribute_is_not_supported() throws ParseException { + weightedset_attribute_is_not_supported("bool"); + } + + @Test + void array_of_raw_attribute_is_not_supported() throws ParseException { + array_attribute_is_not_supported("raw"); + } + + @Test + void weightedset_of_raw_attribute_is_not_supported() throws ParseException { + weightedset_attribute_is_not_supported("raw"); + } + + private static String getSd(String field) { + return joinLines( + "schema test {", + " document test {", + " " + field, + " }", + "}"); + } + +} diff --git a/config-model/src/test/java/com/yahoo/schema/processing/VespaMlModelTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/VespaMlModelTestCase.java index 01e80e0f47a..664cfaf4ad7 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/VespaMlModelTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/VespaMlModelTestCase.java @@ -25,8 +25,8 @@ public class VespaMlModelTestCase { private final Path applicationDir = Path.fromString("src/test/integration/vespa/"); private final String expectedRankConfig = - "constant(constant1).type : tensor(x[3])\n" + "constant(constant1).value : tensor(x[3]):[0.5, 1.5, 2.5]\n" + + "constant(constant1).type : tensor(x[3])\n" + "rankingExpression(foo1).rankingScript : reduce(reduce(input1 * input2, sum, name) * constant(constant1), max, x) * 3.0\n" + "rankingExpression(foo1).input1.type : tensor(name{},x[3])\n" + "rankingExpression(foo1).input2.type : tensor(x[3])\n" + |