aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2020-11-11 10:16:43 +0100
committerGitHub <noreply@github.com>2020-11-11 10:16:43 +0100
commitaced158bbe59aad8b6c2f42de6ab35c0e7cb1f81 (patch)
tree9d83863af8e462f7662ade31f61fd1f03e0a3c58 /config-model/src/main/java/com/yahoo
parent601043a29452896635a0122bf20d358f7a02875c (diff)
parentbd5b2be613ead78636a905d6112501ae8ff306ff (diff)
Merge pull request #15271 from vespa-engine/revert-15179-bjorncs/attribute-validation-cleanup
Revert "Remove handling of tensor-type-change in AttributeChangeValidator" MERGEOK
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java38
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidator.java6
2 files changed, 40 insertions, 4 deletions
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 0aee0675ea7..a10aac30298 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
@@ -6,10 +6,13 @@ import com.yahoo.documentmodel.NewDocumentType;
import com.yahoo.searchdefinition.derived.AttributeFields;
import com.yahoo.searchdefinition.derived.IndexSchema;
import com.yahoo.searchdefinition.document.Attribute;
+import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.searchdefinition.document.HnswIndexParams;
import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeAction;
+import com.yahoo.vespa.model.application.validation.change.VespaRefeedAction;
import com.yahoo.vespa.model.application.validation.change.VespaRestartAction;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -48,11 +51,12 @@ public class AttributeChangeValidator {
this.nextDocType = nextDocType;
}
- public List<VespaConfigChangeAction> validate() {
+ public List<VespaConfigChangeAction> validate(ValidationOverrides overrides, Instant now) {
List<VespaConfigChangeAction> result = new ArrayList<>();
result.addAll(validateAddAttributeAspect());
result.addAll(validateRemoveAttributeAspect());
result.addAll(validateAttributeSettings());
+ result.addAll(validateTensorTypes(overrides, now));
return result;
}
@@ -140,4 +144,36 @@ public class AttributeChangeValidator {
}
}
+ private List<VespaConfigChangeAction> validateTensorTypes(ValidationOverrides overrides, Instant now) {
+ List<VespaConfigChangeAction> result = new ArrayList<>();
+
+ for (Attribute nextAttr : nextFields.attributes()) {
+ Attribute currentAttr = currentFields.getAttribute(nextAttr.getName());
+
+ if (currentAttr != null && currentAttr.tensorType().isPresent()) {
+ // If the tensor attribute is not present on the new attribute, it means that the data type of the attribute
+ // has been changed. This is already handled by DocumentTypeChangeValidator, so we can ignore it here
+ if (!nextAttr.tensorType().isPresent()) {
+ continue;
+ }
+
+ // Tensor attribute has changed type
+ if (!nextAttr.tensorType().get().equals(currentAttr.tensorType().get())) {
+ result.add(createTensorTypeChangedRefeedAction(id, currentAttr, nextAttr, overrides, now));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private static VespaRefeedAction createTensorTypeChangedRefeedAction(ClusterSpec.Id id, Attribute currentAttr, Attribute nextAttr, ValidationOverrides overrides, Instant now) {
+ return VespaRefeedAction.of(id,
+ "tensor-type-change",
+ overrides,
+ new ChangeMessageBuilder(nextAttr.getName()).addChange("tensor type",
+ currentAttr.tensorType().get().toString(),
+ nextAttr.tensorType().get().toString()).build(), now);
+ }
+
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidator.java
index 3dcfbe3629d..68a97f33dfd 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidator.java
@@ -38,20 +38,20 @@ public class DocumentDatabaseChangeValidator {
public List<VespaConfigChangeAction> validate(ValidationOverrides overrides, Instant now) {
List<VespaConfigChangeAction> result = new ArrayList<>();
- result.addAll(validateAttributeChanges());
+ result.addAll(validateAttributeChanges(overrides, now));
result.addAll(validateStructFieldAttributeChanges(overrides, now));
result.addAll(validateIndexingScriptChanges(overrides, now));
result.addAll(validateDocumentTypeChanges(overrides, now));
return result;
}
- private List<VespaConfigChangeAction> validateAttributeChanges() {
+ private List<VespaConfigChangeAction> validateAttributeChanges(ValidationOverrides overrides, Instant now) {
return new AttributeChangeValidator(id,
currentDatabase.getDerivedConfiguration().getAttributeFields(),
currentDatabase.getDerivedConfiguration().getIndexSchema(), currentDocType,
nextDatabase.getDerivedConfiguration().getAttributeFields(),
nextDatabase.getDerivedConfiguration().getIndexSchema(), nextDocType)
- .validate();
+ .validate(overrides, now);
}
private List<VespaConfigChangeAction> validateStructFieldAttributeChanges(ValidationOverrides overrides, Instant now) {