diff options
author | Jon Bratseth <bratseth@oath.com> | 2022-01-26 13:50:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-26 13:50:16 +0100 |
commit | aef6dbaa7a3c4d885485b0905b9c2f84d0aedc6f (patch) | |
tree | ecfb2f612bf7b183d70ee273e0a83bf0dbc5db10 /config-model/src/main/java/com/yahoo/vespa/model | |
parent | 1ecbb8ced4c2599155a2438625987b78e174bd5a (diff) | |
parent | 5869796c08003f41f0ac8e4738414d136b075b1d (diff) |
Merge pull request #20938 from vespa-engine/bratseth/modular-profiles
Bratseth/modular profiles
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/model')
12 files changed, 49 insertions, 94 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java index e2b08a621d1..b977e4c657e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java @@ -34,7 +34,7 @@ public class ComplexAttributeFieldsValidator extends Validator { } SearchCluster searchCluster = (SearchCluster) cluster; for (AbstractSearchCluster.SchemaSpec spec : searchCluster.getLocalSDS()) { - validateComplexFields(searchCluster.getClusterName(), spec.getSearchDefinition().getSearch()); + validateComplexFields(searchCluster.getClusterName(), spec.getSchema()); } } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java index f741c59e414..82c793af70a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java @@ -7,9 +7,9 @@ import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.path.Path; import com.yahoo.searchdefinition.RankingConstant; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.application.validation.ConstantTensorJsonValidator.InvalidConstantTensorException; -import com.yahoo.vespa.model.search.NamedSchema; import java.io.FileNotFoundException; @@ -47,8 +47,8 @@ public class RankingConstantsValidator extends Validator { ApplicationPackage applicationPackage = deployState.getApplicationPackage(); ExceptionMessageCollector exceptionMessageCollector = new ExceptionMessageCollector("Invalid constant tensor file(s):"); - for (NamedSchema sd : deployState.getSchemas()) { - for (RankingConstant rc : sd.getSearch().rankingConstants().asMap().values()) { + for (Schema schema : deployState.getSchemas()) { + for (RankingConstant rc : schema.rankingConstants().asMap().values()) { try { validateRankingConstant(rc, applicationPackage); } catch (InvalidConstantTensorException | FileNotFoundException ex) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java index 14f5c345025..976ed0a0219 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java @@ -11,11 +11,11 @@ import com.yahoo.document.ReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.document.TensorDataType; import com.yahoo.document.WeightedSetDataType; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.search.AbstractSearchCluster; -import com.yahoo.vespa.model.search.NamedSchema; import java.util.List; @@ -35,26 +35,26 @@ public class SearchDataTypeValidator extends Validator { continue; } for (AbstractSearchCluster.SchemaSpec spec : cluster.getLocalSDS()) { - SDDocumentType docType = spec.getSearchDefinition().getSearch().getDocument(); + SDDocumentType docType = spec.getSchema().getDocument(); if (docType == null) { continue; } - validateDocument(cluster, spec.getSearchDefinition(), docType); + validateDocument(cluster, spec.getSchema(), docType); } } } - private void validateDocument(AbstractSearchCluster cluster, NamedSchema def, SDDocumentType doc) { + private void validateDocument(AbstractSearchCluster cluster, Schema schema, SDDocumentType doc) { for (SDDocumentType child : doc.getTypes()) { - validateDocument(cluster, def, child); + validateDocument(cluster, schema, child); } for (Field field : doc.fieldSet()) { DataType fieldType = field.getDataType(); - disallowIndexingOfMaps(cluster, def, field); + disallowIndexingOfMaps(cluster, schema, field); if ( ! isSupportedInSearchClusters(fieldType)) { throw new IllegalArgumentException("Field type '" + fieldType.getName() + "' is illegal for search " + - "clusters (field '" + field.getName() + "' in definition '" + - def.getName() + "' for cluster '" + cluster.getClusterName() + "')."); + "clusters (field '" + field.getName() + "' in schema '" + + schema.getName() + "' for cluster '" + cluster.getClusterName() + "')."); } } } @@ -84,12 +84,12 @@ public class SearchDataTypeValidator extends Validator { } } - private void disallowIndexingOfMaps(AbstractSearchCluster cluster, NamedSchema def, Field field) { + private void disallowIndexingOfMaps(AbstractSearchCluster cluster, Schema schema, Field field) { DataType fieldType = field.getDataType(); if ((fieldType instanceof MapDataType) && (((SDField) field).doesIndexing())) { throw new IllegalArgumentException("Field type '" + fieldType.getName() + "' cannot be indexed for search " + "clusters (field '" + field.getName() + "' in definition '" + - def.getName() + "' for cluster '" + cluster.getClusterName() + "')."); + schema.getName() + "' for cluster '" + cluster.getClusterName() + "')."); } } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java index 0e53417aea9..e0b7c3b288a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java @@ -125,7 +125,7 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> QrSearchersConfig.Searchcluster.Builder scB = new QrSearchersConfig.Searchcluster.Builder(). name(sys.getClusterName()); for (AbstractSearchCluster.SchemaSpec spec : sys.getLocalSDS()) { - scB.searchdef(spec.getSearchDefinition().getName()); + scB.searchdef(spec.getSchema().getName()); } scB.rankprofiles(new QrSearchersConfig.Searchcluster.Rankprofiles.Builder().configid(sys.getConfigId())); scB.indexingmode(QrSearchersConfig.Searchcluster.Indexingmode.Enum.valueOf(sys.getIndexingModeName())); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java index e2579d95fc0..7eefa2e5e74 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java @@ -116,7 +116,7 @@ public class LocalProvider extends Provider implements List<String> documentTypes = new ArrayList<>(); for (AbstractSearchCluster.SchemaSpec spec : searchCluster.getLocalSDS()) { - documentTypes.add(spec.getSearchDefinition().getSearch().getDocument().getName()); + documentTypes.add(spec.getSchema().getDocument().getName()); } return documentTypes; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java index c703584eccc..6d21e0ad10e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java @@ -5,6 +5,7 @@ import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.documentmodel.NewDocumentType; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.config.search.DispatchConfig; import com.yahoo.vespa.config.search.core.ProtonConfig; import com.yahoo.vespa.model.builder.UserConfigBuilder; @@ -14,7 +15,6 @@ import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; import com.yahoo.vespa.model.content.cluster.ContentCluster; import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.IndexedSearchCluster; -import com.yahoo.vespa.model.search.NamedSchema; import com.yahoo.vespa.model.search.NodeSpec; import com.yahoo.vespa.model.search.SchemaDefinitionXMLHandler; import com.yahoo.vespa.model.search.SearchCluster; @@ -259,17 +259,15 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster> private void addSchemas(DeployState deployState, List<ModelElement> searchDefs, AbstractSearchCluster sc) { for (ModelElement e : searchDefs) { SchemaDefinitionXMLHandler schemaDefinitionXMLHandler = new SchemaDefinitionXMLHandler(e); - NamedSchema searchDefinition = - schemaDefinitionXMLHandler.getResponsibleSearchDefinition(deployState.getSchemas()); - if (searchDefinition == null) + Schema schema = schemaDefinitionXMLHandler.findResponsibleSchema(deployState.getSchemas()); + if (schema == null) throw new IllegalArgumentException("Schema '" + schemaDefinitionXMLHandler.getName() + "' referenced in " + this + " does not exist"); // TODO: remove explicit building of user configs when the complete content model is built using builders. - sc.getLocalSDS().add(new AbstractSearchCluster.SchemaSpec(searchDefinition, + sc.getLocalSDS().add(new AbstractSearchCluster.SchemaSpec(schema, UserConfigBuilder.build(e.getXml(), deployState, deployState.getDeployLogger()))); - //need to get the document names from this sdfile - sc.addDocumentNames(searchDefinition); + sc.addDocumentNames(schema); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java index 1488f5fd112..38b1d42862e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java @@ -87,7 +87,7 @@ public class ConvertedModel { ApplicationPackage applicationPackage = context.rankProfile().applicationPackage(); ImportedMlModel sourceModel = // TODO: Convert to name here, make sure its done just one way context.importedModels().get(sourceModelFile(applicationPackage, modelPath)); - ModelName modelName = new ModelName(context.rankProfile().getName(), modelPath, pathIsFile); + ModelName modelName = new ModelName(context.rankProfile().name(), modelPath, pathIsFile); if (sourceModel == null && ! new ModelStore(applicationPackage, modelName).exists()) throw new IllegalArgumentException("No model '" + modelPath + "' is available. Available models: " + diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java index 19b1f39c87d..93a264ae4bb 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java @@ -5,6 +5,7 @@ import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.config.model.producer.UserConfigRepo; import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; import com.yahoo.search.config.IndexInfoConfig; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.config.search.AttributesConfig; import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.vespa.configdefinition.IlscriptsConfig; @@ -37,9 +38,8 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer<Abstr this.index = index; } - public void addDocumentNames(NamedSchema searchDefinition) { - String dName = searchDefinition.getSearch().getDocument().getDocumentName().getName(); - documentNames.add(dName); + public void addDocumentNames(Schema schema) { + documentNames.add(schema.getDocument().getDocumentName().getName()); } /** Returns a List with document names used in this search cluster */ @@ -51,16 +51,15 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer<Abstr public String getClusterName() { return clusterName; } public final String getIndexingModeName() { return getIndexingMode().getName(); } - public final boolean isRealtime() { return getIndexingMode() == IndexingMode.REALTIME; } public final boolean isStreaming() { return getIndexingMode() == IndexingMode.STREAMING; } public final AbstractSearchCluster setQueryTimeout(Double to) { - this.queryTimeout=to; + this.queryTimeout = to; return this; } public final AbstractSearchCluster setVisibilityDelay(double delay) { - this.visibilityDelay=delay; + this.visibilityDelay = delay; return this; } @@ -103,16 +102,16 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer<Abstr public static final class SchemaSpec { - private final NamedSchema searchDefinition; + private final Schema schema; private final UserConfigRepo userConfigRepo; - public SchemaSpec(NamedSchema searchDefinition, UserConfigRepo userConfigRepo) { - this.searchDefinition = searchDefinition; + public SchemaSpec(Schema schema, UserConfigRepo userConfigRepo) { + this.schema = schema; this.userConfigRepo = userConfigRepo; } - public NamedSchema getSearchDefinition() { - return searchDefinition; + public Schema getSchema() { + return schema; } public UserConfigRepo getUserConfigs() { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java index a68993be543..fb7c6696b54 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java @@ -196,10 +196,9 @@ public class IndexedSearchCluster extends SearchCluster @Override protected void deriveAllSchemas(List<SchemaSpec> localSearches, DeployState deployState) { for (SchemaSpec spec : localSearches) { - Schema schema = spec.getSearchDefinition().getSearch(); - if ( ! (schema instanceof DocumentOnlySchema)) { - DocumentDatabase db = new DocumentDatabase(this, schema.getName(), - new DerivedConfiguration(schema, + if ( ! (spec.getSchema() instanceof DocumentOnlySchema)) { + DocumentDatabase db = new DocumentDatabase(this, spec.getSchema().getName(), + new DerivedConfiguration(spec.getSchema(), deployState.getDeployLogger(), deployState.getProperties(), deployState.rankProfileRegistry(), diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java b/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java deleted file mode 100644 index 334493b4a92..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.search; - -import com.yahoo.searchdefinition.Schema; - -import java.util.Collection; - -/** - * @author Tony Vaagenes - */ -// TODO: This class is quite pointless -public class NamedSchema { - - private final Schema schema; - private final String name; - - public static final String fileNameSuffix = ".sd"; - - public Schema getSearch() { - return schema; - } - - public String getName() { - return name; - } - - public NamedSchema(String name, Schema schema) { - this.name = name; - this.schema = schema; - } - - //Find search definition from a collection with the name specified - public static NamedSchema findByName(String schemaName, Collection<NamedSchema> schemas) { - for (NamedSchema candidate : schemas) { - if (candidate.getName().equals(schemaName) ) - return candidate; - } - - return null; - } - - // Used by admin interface - public String getFilename() { - return getName() + fileNameSuffix; - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SchemaDefinitionXMLHandler.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SchemaDefinitionXMLHandler.java index 881b68e8396..b4082308195 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SchemaDefinitionXMLHandler.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SchemaDefinitionXMLHandler.java @@ -1,9 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.builder.xml.dom.ModelElement; import java.io.Serializable; +import java.util.Collection; import java.util.List; /** @@ -13,19 +15,23 @@ import java.util.List; */ public class SchemaDefinitionXMLHandler implements Serializable { - private String sdName; + private String schemaName; public SchemaDefinitionXMLHandler(ModelElement elem) { - sdName = elem.stringAttribute("name"); - if (sdName == null) { - sdName = elem.stringAttribute("type"); + schemaName = elem.stringAttribute("name"); + if (schemaName == null) { + schemaName = elem.stringAttribute("type"); } } - public String getName() { return sdName; } + public String getName() { return schemaName; } - public NamedSchema getResponsibleSearchDefinition(List<NamedSchema> schemas) { - return NamedSchema.findByName(getName(), schemas ); + public Schema findResponsibleSchema(List<Schema> schemas) { + for (Schema candidate : schemas) { + if (candidate.getName().equals(schemaName) ) + return candidate; + } + return null; } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java index bacba9ea61d..42bb2a1da29 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java @@ -85,7 +85,7 @@ public class StreamingSearchCluster extends SearchCluster implements @Override protected void deriveAllSchemas(List<SchemaSpec> local, DeployState deployState) { if (local.size() == 1) { - deriveSingleSearchDefinition(local.get(0).getSearchDefinition().getSearch(), deployState); + deriveSingleSearchDefinition(local.get(0).getSchema(), deployState); } else if (local.size() > 1){ throw new IllegalArgumentException("Only a single schema is supported, got " + local.size()); } |