diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-08-12 09:06:57 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-08-12 09:06:57 +0200 |
commit | 43597d9f7e1c65563d5fddcb13f66000ad98b9e6 (patch) | |
tree | 32c93f0d311839755f5549e8665a97030874e3f1 | |
parent | 96d88f5e9273060bb8d264e2988cb854048cf1d6 (diff) |
Control swappable
9 files changed, 61 insertions, 12 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java index 125b0cf2763..f9520159383 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java @@ -222,6 +222,9 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce if (attribute.isHuge()) { aaB.huge(true); } + if (attribute.isSwappable()) { + aaB.swappable(true); + } if (attribute.getSorting().isDescending()) { aaB.sortascending(false); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java index 0cf7a031dbc..0dacb832ab7 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java @@ -57,6 +57,7 @@ public final class Attribute implements Cloneable, Serializable { private boolean fastAccess = false; private boolean huge = false; private boolean mutable = false; + private boolean swappable = false; private int arity = BooleanIndexDefinition.DEFAULT_ARITY; private long lowerBound = BooleanIndexDefinition.DEFAULT_LOWER_BOUND; private long upperBound = BooleanIndexDefinition.DEFAULT_UPPER_BOUND; @@ -194,6 +195,7 @@ public final class Attribute implements Cloneable, Serializable { public boolean isFastSearch() { return fastSearch; } public boolean isFastAccess() { return fastAccess; } public boolean isHuge() { return huge; } + public boolean isSwappable() { return swappable; } public boolean isPosition() { return isPosition; } public boolean isMutable() { return mutable; } @@ -226,6 +228,7 @@ public final class Attribute implements Cloneable, Serializable { public void setEnableOnlyBitVector(boolean enableOnlyBitVector) { this.enableOnlyBitVector = enableOnlyBitVector; } public void setFastSearch(boolean fastSearch) { this.fastSearch = fastSearch; } public void setHuge(boolean huge) { this.huge = huge; } + public void setSwappable(boolean swappable) { this.swappable = swappable; } public void setFastAccess(boolean fastAccess) { this.fastAccess = fastAccess; } public void setPosition(boolean position) { this.isPosition = position; } public void setMutable(boolean mutable) { this.mutable = mutable; } @@ -355,8 +358,9 @@ public final class Attribute implements Cloneable, Serializable { @Override public int hashCode() { return Objects.hash( - name, type, collectionType, sorting, dictionary, isPrefetch(), fastAccess, removeIfZero, createIfNonExistent, - isPosition, huge, enableBitVectors, enableOnlyBitVector, tensorType, referenceDocumentType, distanceMetric, hnswIndexParams); + name, type, collectionType, sorting, dictionary, isPrefetch(), fastAccess, removeIfZero, + createIfNonExistent, isPosition, huge, mutable, swappable, enableBitVectors, enableOnlyBitVector, + tensorType, referenceDocumentType, distanceMetric, hnswIndexParams); } @Override @@ -379,6 +383,8 @@ public final class Attribute implements Cloneable, Serializable { if (this.enableOnlyBitVector != other.enableOnlyBitVector) return false; if (this.fastSearch != other.fastSearch) return false; if (this.huge != other.huge) return false; + if (this.mutable != other.mutable) return false; + if (this.swappable != other.swappable) return false; if (! this.sorting.equals(other.sorting)) return false; if (! Objects.equals(dictionary, other.dictionary)) return false; if (! Objects.equals(tensorType, other.tensorType)) return false; diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/AttributeOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/AttributeOperation.java index 56e241adb8e..8c6c9ecd696 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/AttributeOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/AttributeOperation.java @@ -18,9 +18,10 @@ public class AttributeOperation implements FieldOperation, FieldOperationContain private Boolean fastSearch; private Boolean fastAccess; private Boolean mutable; + private Boolean swappable; private Boolean enableBitVectors; private Boolean enableOnlyBitVector; - //TODO: Husk sorting!! + //TODO: Remember sorting!! private boolean doAlias = false; private String alias; private String aliasedName; @@ -73,6 +74,9 @@ public class AttributeOperation implements FieldOperation, FieldOperationContain public void setMutable(Boolean mutable) { this.mutable = mutable; } + public void setSwappable(Boolean swappable) { + this.swappable = swappable; + } public Boolean getEnableBitVectors() { return enableBitVectors; @@ -131,6 +135,9 @@ public class AttributeOperation implements FieldOperation, FieldOperationContain if (huge != null) { attribute.setHuge(huge); } + if (swappable != null) { + attribute.setSwappable(swappable); + } if (fastSearch != null) { attribute.setFastSearch(fastSearch); } 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 7a17fe5e80a..a5f4683c09b 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 @@ -105,6 +105,7 @@ public class AttributeChangeValidator { validateAttributeSetting(id, currAttr, nextAttr, AttributeChangeValidator::extractDictionaryType, "dictionary: btree/hash", result); validateAttributeSetting(id, currAttr, nextAttr, AttributeChangeValidator::extractDictionaryCase, "dictionary: cased/uncased", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::isHuge, "huge", result); + validateAttributeSetting(id, currAttr, nextAttr, Attribute::isSwappable, "swappable", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::densePostingListThreshold, "dense-posting-list-threshold", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::isEnabledOnlyBitVector, "rank: filter", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::distanceMetric, "distance-metric", result); diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index fb24b50aa99..3ef2474a0bb 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -299,6 +299,7 @@ TOKEN : | < ENABLEONLYBITVECTOR: "enable-only-bit-vector" > | < FASTACCESS: "fast-access" > | < MUTABLE: "mutable" > +| < SWAPPABLE: "swappable" > | < FASTSEARCH: "fast-search" > | < HUGE: "huge" > | < TENSOR_TYPE: "tensor" ("<" (~["<",">"])+ ">")? "(" (~["(",")"])+ ")" > @@ -1229,11 +1230,12 @@ Object attributeSetting(FieldOperationContainer field, AttributeOperation attrib } { ( - <HUGE> { attribute.setHuge(true); } - | <FASTSEARCH> { attribute.setFastSearch(true); } - | <FASTACCESS> { attribute.setFastAccess(true); } - | <MUTABLE> { attribute.setMutable(true); } - | <ENABLEBITVECTORS> { attribute.setEnableBitVectors(true); } + <HUGE> { attribute.setHuge(true); } + | <FASTSEARCH> { attribute.setFastSearch(true); } + | <FASTACCESS> { attribute.setFastAccess(true); } + | <MUTABLE> { attribute.setMutable(true); } + | <SWAPPABLE> { attribute.setSwappable(true); } + | <ENABLEBITVECTORS> { attribute.setEnableBitVectors(true); } | <ENABLEONLYBITVECTOR> { attribute.setEnableOnlyBitVector(true); } | sorting(field, attributeName) | <ALIAS> { String alias; String aliasedName=attributeName; } [aliasedName = identifier()] <COLON> alias = identifierWithDash() { @@ -2736,6 +2738,7 @@ String identifier() : { } | <SECONDPHASE> | <SORTING> | <SOURCE> + | <SWAPPABLE> | <SSCONTEXTUAL> | <SSOVERRIDE> | <SSTITLE> diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java index 83cad4cf266..87cffcf1b78 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java @@ -112,6 +112,33 @@ public class AttributeSettingsTestCase extends SchemaTestCase { SDField field = (SDField) search.getDocument().getField("f"); return field.getAttributes().get(field.getName()); } + + @Test + public void requireThatSwappableIsDefaultOff() throws ParseException { + Attribute attr = getAttributeF( + "search test {\n" + + " document test { \n" + + " field f type int { \n" + + " indexing: attribute \n" + + " }\n" + + " }\n" + + "}\n"); + assertFalse(attr.isSwappable()); + } + @Test + public void requireThatSwappableCanBeSet() throws ParseException { + Attribute attr = getAttributeF( + "search test {\n" + + " document test { \n" + + " field f type int { \n" + + " indexing: attribute \n" + + " attribute: swappable \n" + + " }\n" + + " }\n" + + "}\n"); + assertFalse(attr.isSwappable()); + } + @Test public void requireThatMutableIsDefaultOff() throws ParseException { Attribute attr = getAttributeF( @@ -219,6 +246,7 @@ public class AttributeSettingsTestCase extends SchemaTestCase { single.setEnableOnlyBitVector(true); single.setFastSearch(true); single.setHuge(true); + single.setSwappable(true); single.setFastAccess(true); single.setPosition(true); single.setArity(5); @@ -241,6 +269,7 @@ public class AttributeSettingsTestCase extends SchemaTestCase { assertTrue(array.isEnabledOnlyBitVector()); assertTrue(array.isFastSearch()); assertTrue(array.isHuge()); + assertTrue(array.isSwappable()); assertTrue(array.isFastAccess()); assertTrue(array.isPosition()); assertEquals(5, array.arity()); diff --git a/configdefinitions/src/vespa/attributes.def b/configdefinitions/src/vespa/attributes.def index 7d7f417bce0..d8dbb6e9ddd 100644 --- a/configdefinitions/src/vespa/attributes.def +++ b/configdefinitions/src/vespa/attributes.def @@ -11,7 +11,7 @@ attribute[].removeifzero bool default=false attribute[].createifnonexistent bool default=false attribute[].fastsearch bool default=false attribute[].huge bool default=false -attribute[].swapable bool default=false +attribute[].swappable bool default=false # An attribute marked mutable can be updated by a query. attribute[].ismutable bool default=false attribute[].sortascending bool default=true diff --git a/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp b/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp index 729067f1c6b..0fcd4db5bec 100644 --- a/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp +++ b/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp @@ -239,7 +239,7 @@ TEST("require that config can be converted") { CACA a; EXPECT_TRUE(!CC::convert(a).swapable()); - a.swapable = true; + a.swappable = true; EXPECT_TRUE(CC::convert(a).swapable()); } { // tensor @@ -415,4 +415,4 @@ TEST("require that we can get readable attribute by name") } // namespace search -TEST_MAIN() { TEST_RUN_ALL(); }
\ No newline at end of file +TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/vespa/searchlib/attribute/configconverter.cpp b/searchlib/src/vespa/searchlib/attribute/configconverter.cpp index cff0c0b1063..24951a16f0d 100644 --- a/searchlib/src/vespa/searchlib/attribute/configconverter.cpp +++ b/searchlib/src/vespa/searchlib/attribute/configconverter.cpp @@ -108,7 +108,7 @@ ConfigConverter::convert(const AttributesConfig::Attribute & cfg) retval.setIsFilter(cfg.enableonlybitvector); retval.setFastAccess(cfg.fastaccess); retval.setMutable(cfg.ismutable); - retval.setSwapable(cfg.swapable); + retval.setSwapable(cfg.swappable); predicateParams.setArity(cfg.arity); predicateParams.setBounds(cfg.lowerbound, cfg.upperbound); predicateParams.setDensePostingListThreshold(cfg.densepostinglistthreshold); |