summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2022-05-19 13:14:52 +0000
committerGeir Storli <geirst@yahooinc.com>2022-05-19 13:14:52 +0000
commit06f290f5477996d86cbc4a5d98da68e5cf0cb367 (patch)
tree92dc39f69290b50109676e2ae11f7c7636995fda /config-model
parent340f78ced167cc2bbf02c7541664b0c305b6a1e9 (diff)
Changing 'fast-rank' on an attribute should trigger the restart action.
Add more testing of 'fast-rank' on un-supported attributes.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/schema/document/Attribute.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java1
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/TensorFieldTestCase.java11
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java8
4 files changed, 24 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/document/Attribute.java b/config-model/src/main/java/com/yahoo/schema/document/Attribute.java
index f2279a52855..5593c3f8cdf 100644
--- a/config-model/src/main/java/com/yahoo/schema/document/Attribute.java
+++ b/config-model/src/main/java/com/yahoo/schema/document/Attribute.java
@@ -232,7 +232,9 @@ public final class Attribute implements Cloneable, Serializable {
public void setEnableBitVectors(boolean enableBitVectors) { this.enableBitVectors = enableBitVectors; }
public void setEnableOnlyBitVector(boolean enableOnlyBitVector) { this.enableOnlyBitVector = enableOnlyBitVector; }
public void setFastRank(boolean value) {
- Supplier<IllegalArgumentException> badGen = () -> new IllegalArgumentException("fast-rank is only valid for tensor attributes, invalid for: "+this);
+ Supplier<IllegalArgumentException> badGen = () ->
+ new IllegalArgumentException("The " + toString() + " does not support 'fast-rank'. " +
+ "Only supported for tensor types with at least one mapped dimension");
var tt = tensorType.orElseThrow(badGen);
for (var dim : tt.dimensions()) {
if (dim.isMapped()) {
@@ -425,7 +427,7 @@ public final class Attribute implements Cloneable, Serializable {
@Override
public String toString() {
- return "attribute '" + name + "' (" + type + ")";
+ return "attribute '" + name + "' (" + (tensorType.isPresent() ? tensorType.get() : type) + ")";
}
public Set<String> getAliases() {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java
index 432424c8027..cfb641882f6 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java
@@ -110,6 +110,7 @@ public class AttributeChangeValidator {
Attribute current = currentFields.getAttribute(next.getName());
if (current != null) {
validateAttributePredicate(id, current, next, Attribute::isFastSearch, "fast-search", result);
+ validateAttributePredicate(id, current, next, Attribute::isFastRank, "fast-rank", result);
validateAttributePredicate(id, current, next, Attribute::isFastAccess, "fast-access", result);
validateAttributeProperty(id, current, next, AttributeChangeValidator::extractDictionaryType, "dictionary: btree/hash", result);
validateAttributeProperty(id, current, next, AttributeChangeValidator::extractDictionaryCase, "dictionary: cased/uncased", result);
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/TensorFieldTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/TensorFieldTestCase.java
index 67c77508e3b..9164f361a92 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/TensorFieldTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/TensorFieldTestCase.java
@@ -55,6 +55,17 @@ public class TensorFieldTestCase {
}
@Test
+ public void requireThatIndexedTensorAttributeCannotBeFastRank() throws ParseException {
+ try {
+ createFromString(getSd("field f1 type tensor(x[3]) { indexing: attribute \n attribute: fast-rank }"));
+ fail("Expected exception");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("The attribute 'f1' (tensor(x[3])) does not support 'fast-rank'. Only supported for tensor types with at least one mapped dimension", e.getMessage());
+ }
+ }
+
+ @Test
public void requireThatIllegalTensorTypeSpecThrowsException() throws ParseException {
try {
createFromString(getSd("field f1 type tensor(invalid) { indexing: attribute }"));
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java
index 3cfde4c4d19..c3aa387da54 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java
@@ -76,6 +76,14 @@ public class AttributeChangeValidatorTest {
}
@Test
+ public void changing_fast_rank_require_restart() throws Exception {
+ new Fixture("field f1 type tensor(x{}) { indexing: attribute }",
+ "field f1 type tensor(x{}) { indexing: attribute \n attribute: fast-rank }").
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: add attribute 'fast-rank'"));
+ }
+
+ @Test
public void changing_btree2hash_require_restart() throws Exception {
new Fixture("field f1 type long { indexing: attribute\n attribute: fast-search\n dictionary: btree}",
"field f1 type long { indexing: attribute\n attribute: fast-search\n dictionary: hash }").