diff options
author | Tor Egge <Tor.Egge@yahooinc.com> | 2022-10-10 16:20:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-10 16:20:35 +0200 |
commit | 08f7a121fff008dd1307b106bd1b7d7a84433fe6 (patch) | |
tree | a40bf7e82761a73d442098db93bf0c28f4cd2d8c | |
parent | 25739b46605f7376c2b6e8b9a0ea80939ae04311 (diff) | |
parent | 62a65a21ae3defcfe1352d9536a3571dcedad320 (diff) |
Merge pull request #24378 from vespa-engine/toregge/allow-paged-setting-for-tensor-attributes-without-fast-rank-setting
Allow paged setting for tensor attributes without fast-rank setting.
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/processing/PagedAttributeValidator.java | 8 | ||||
-rw-r--r-- | config-model/src/test/java/com/yahoo/schema/processing/PagedAttributeValidatorTestCase.java | 34 |
2 files changed, 28 insertions, 14 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/processing/PagedAttributeValidator.java b/config-model/src/main/java/com/yahoo/schema/processing/PagedAttributeValidator.java index 793505acd01..6f470cfdc56 100644 --- a/config-model/src/main/java/com/yahoo/schema/processing/PagedAttributeValidator.java +++ b/config-model/src/main/java/com/yahoo/schema/processing/PagedAttributeValidator.java @@ -41,19 +41,19 @@ public class PagedAttributeValidator extends Processor { private void validatePagedSetting(Field field, Attribute attribute) { if (!isSupportedType(attribute)) { - fail(schema, field, "The 'paged' attribute setting is not supported for non-dense tensor, predicate and reference types"); + fail(schema, field, "The 'paged' attribute setting is not supported for fast-rank tensor and predicate types"); } } private boolean isSupportedType(Attribute attribute) { var type = attribute.getType(); return (type != Attribute.Type.PREDICATE) && - (isSupportedTensorType(attribute.tensorType())); + (isSupportedTensorType(attribute.tensorType(), attribute.isFastRank())); } - private boolean isSupportedTensorType(Optional<TensorType> tensorType) { + private boolean isSupportedTensorType(Optional<TensorType> tensorType, boolean fastRank) { if (tensorType.isPresent()) { - return isDenseTensorType(tensorType.get()); + return !fastRank; } return true; } diff --git a/config-model/src/test/java/com/yahoo/schema/processing/PagedAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/PagedAttributeValidatorTestCase.java index 719db2ffdcc..9de44d28c09 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/PagedAttributeValidatorTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/PagedAttributeValidatorTestCase.java @@ -71,8 +71,13 @@ public class PagedAttributeValidatorTestCase { } @Test - void non_dense_tensor_attribute_does_not_support_paged_setting() throws ParseException { - assertPagedSettingNotSupported("tensor(x{},y[2])"); + void non_dense_none_fast_rank_tensor_attribute_supports_paged_setting() throws ParseException { + assertPagedSupported("tensor(x{},y[2])"); + } + + @Test + void non_dense_fast_rank_tensor_attribute_does_not_support_paged_setting() throws ParseException { + assertPagedSettingNotSupported("tensor(x{},y[2])", true); } @Test @@ -82,36 +87,45 @@ public class PagedAttributeValidatorTestCase { @Test void reference_attribute_support_paged_setting() throws ParseException { - assertPagedSupported("reference<parent>", Optional.of(getSd("parent", "int"))); + assertPagedSupported("reference<parent>", Optional.of(getSd("parent", "int", false))); } private void assertPagedSettingNotSupported(String fieldType) throws ParseException { - assertPagedSettingNotSupported(fieldType, Optional.empty()); + assertPagedSettingNotSupported(fieldType, false); + } + + private void assertPagedSettingNotSupported(String fieldType, boolean fastRank) throws ParseException { + assertPagedSettingNotSupported(fieldType, fastRank, Optional.empty()); } - private void assertPagedSettingNotSupported(String fieldType, Optional<String> parentSd) throws ParseException { + private void assertPagedSettingNotSupported(String fieldType, boolean fastRank, Optional<String> parentSd) throws ParseException { try { if (parentSd.isPresent()) { - createFromStrings(new BaseDeployLogger(), parentSd.get(), getSd(fieldType)); + createFromStrings(new BaseDeployLogger(), parentSd.get(), getSd(fieldType, fastRank)); } else { - createFromString(getSd(fieldType)); + createFromString(getSd(fieldType, fastRank)); } fail("Expected exception"); } catch (IllegalArgumentException e) { - assertEquals("For schema 'test', field 'foo': The 'paged' attribute setting is not supported for non-dense tensor, predicate and reference types", + assertEquals("For schema 'test', field 'foo': The 'paged' attribute setting is not supported for fast-rank tensor and predicate types", e.getMessage()); } } private String getSd(String fieldType) { - return getSd("test", fieldType); + return getSd(fieldType, false); + } + + private String getSd(String fieldType, boolean fastRank) { + return getSd("test", fieldType, fastRank); } - private String getSd(String docType, String fieldType) { + private String getSd(String docType, String fieldType, boolean fastRank) { return joinLines( "schema " + docType + " {", " document " + docType + " {", " field foo type " + fieldType + "{", + (fastRank ? "attribute: fast-rank" : ""), " indexing: attribute", " attribute: paged", " }", |