diff options
Diffstat (limited to 'config-model')
20 files changed, 457 insertions, 138 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java index b8d63ba3778..4df7a76031a 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java @@ -24,7 +24,6 @@ import com.yahoo.config.model.api.ValidationParameters; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.provision.HostsXmlProvisioner; -import com.yahoo.config.model.provision.InMemoryProvisioner; import com.yahoo.config.model.provision.SingleNodeProvisioner; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.config.provision.DockerImage; @@ -41,7 +40,6 @@ import com.yahoo.vespa.config.ConfigDefinitionKey; import com.yahoo.vespa.documentmodel.DocumentModel; import com.yahoo.vespa.model.container.search.QueryProfiles; import com.yahoo.vespa.model.container.search.QueryProfilesBuilder; -import com.yahoo.vespa.model.container.search.SemanticRuleBuilder; import com.yahoo.vespa.model.container.search.SemanticRules; import java.io.File; @@ -60,6 +58,8 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutorService; +import static com.yahoo.vespa.model.container.search.SemanticRules.SemanticRuleBuilder; + /** * Contains various state during deploy that should be available in all builders of a {@link com.yahoo.config.model.ConfigModel} * diff --git a/config-model/src/main/java/com/yahoo/schema/Index.java b/config-model/src/main/java/com/yahoo/schema/Index.java index 190081cf80f..aa1d226d12e 100644 --- a/config-model/src/main/java/com/yahoo/schema/Index.java +++ b/config-model/src/main/java/com/yahoo/schema/Index.java @@ -15,7 +15,7 @@ import java.util.Optional; import java.util.Set; /** - * An index definition in a search definition. + * An index definition in a schema. * Two indices are equal if they have the same name and the same settings, except * alias settings (which are excluded). * diff --git a/config-model/src/main/java/com/yahoo/schema/derived/Index.java b/config-model/src/main/java/com/yahoo/schema/derived/Index.java index 3b5e617d3dc..2f5b674abee 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/Index.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/Index.java @@ -16,11 +16,11 @@ public class Index { /** The index type enumeration */ public static class Type { - public static final Type TEXT=new Type("text"); - public static final Type INT64=new Type("long"); - public static final Type BOOLEANTREE=new Type("booleantree"); + public static final Type TEXT = new Type("text"); + public static final Type INT64 = new Type("long"); + public static final Type BOOLEANTREE = new Type("booleantree"); - private String name; + private final String name; private Type(String name) { this.name=name; diff --git a/config-model/src/main/java/com/yahoo/schema/derived/SchemaInfo.java b/config-model/src/main/java/com/yahoo/schema/derived/SchemaInfo.java index 517a43fe129..291c67cae02 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/SchemaInfo.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/SchemaInfo.java @@ -1,7 +1,21 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.schema.derived; +import com.yahoo.document.ArrayDataType; +import com.yahoo.document.DataType; +import com.yahoo.document.MapDataType; +import com.yahoo.document.PrimitiveDataType; +import com.yahoo.document.ReferenceDataType; +import com.yahoo.document.StructuredDataType; +import com.yahoo.document.TensorDataType; +import com.yahoo.document.WeightedSetDataType; +import com.yahoo.document.annotation.AnnotationReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; +import com.yahoo.schema.document.Attribute; +import com.yahoo.schema.document.FieldSet; +import com.yahoo.schema.document.ImmutableSDField; import com.yahoo.search.config.SchemaInfoConfig; +import com.yahoo.schema.Index; import com.yahoo.schema.RankProfile; import com.yahoo.schema.RankProfileRegistry; import com.yahoo.schema.Schema; @@ -9,6 +23,7 @@ import com.yahoo.searchlib.rankingexpression.Reference; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; @@ -52,11 +67,79 @@ public final class SchemaInfo extends Derived implements SchemaInfoConfig.Produc public void getConfig(SchemaInfoConfig.Builder builder) { var schemaBuilder = new SchemaInfoConfig.Schema.Builder(); schemaBuilder.name(schema.getName()); + addFieldsConfig(schemaBuilder); + addFieldSetConfig(schemaBuilder); addSummaryConfig(schemaBuilder); addRankProfilesConfig(schemaBuilder); builder.schema(schemaBuilder); } + private void addFieldsConfig(SchemaInfoConfig.Schema.Builder schemaBuilder) { + for (var field : schema.allFieldsList()) { + addFieldConfig(field, schemaBuilder); + for (var index : field.getIndices().values()) { + if ( ! index.getName().equals(field.getName())) // additional index + addFieldConfig(index, field.getDataType(), schemaBuilder); + } + for (var attribute : field.getAttributes().values()) { + if ( ! attribute.getName().equals(field.getName())) // additional attribute + addFieldConfig(attribute, field.getDataType(), schemaBuilder); + } + } + } + + private void addFieldConfig(ImmutableSDField field, SchemaInfoConfig.Schema.Builder schemaBuilder) { + var fieldBuilder = new SchemaInfoConfig.Schema.Field.Builder(); + fieldBuilder.name(field.getName()); + fieldBuilder.type(toTypeSpec(field.getDataType())); + for (var alias : field.getAliasToName().entrySet()) { + if (alias.getValue().equals(field.getName())) + fieldBuilder.alias(alias.getKey()); + } + fieldBuilder.attribute(field.doesAttributing()); + fieldBuilder.index(field.doesIndexing()); + schemaBuilder.field(fieldBuilder); + } + + // TODO: Make fields and indexes 1-1 so that this can be removed + private void addFieldConfig(Index index, DataType type, SchemaInfoConfig.Schema.Builder schemaBuilder) { + var fieldBuilder = new SchemaInfoConfig.Schema.Field.Builder(); + fieldBuilder.name(index.getName()); + fieldBuilder.type(toTypeSpec(type)); + for (Iterator<String> i = index.aliasIterator(); i.hasNext(); ) + fieldBuilder.alias(i.next()); + fieldBuilder.attribute(false); + fieldBuilder.index(true); + schemaBuilder.field(fieldBuilder); + } + + // TODO: Make fields and attributes 1-1 so that this can be removed + private void addFieldConfig(Attribute attribute, DataType type, SchemaInfoConfig.Schema.Builder schemaBuilder) { + var fieldBuilder = new SchemaInfoConfig.Schema.Field.Builder(); + fieldBuilder.name(attribute.getName()); + fieldBuilder.type(toTypeSpec(type)); + for (var alias : attribute.getAliases()) + fieldBuilder.alias(alias); + fieldBuilder.attribute(true); + fieldBuilder.index(false); + schemaBuilder.field(fieldBuilder); + } + + private void addFieldSetConfig(SchemaInfoConfig.Schema.Builder schemaBuilder) { + for (var fieldSet : schema.fieldSets().builtInFieldSets().values()) + addFieldSetConfig(fieldSet, schemaBuilder); + for (var fieldSet : schema.fieldSets().userFieldSets().values()) + addFieldSetConfig(fieldSet, schemaBuilder); + } + + private void addFieldSetConfig(FieldSet fieldSet, SchemaInfoConfig.Schema.Builder schemaBuilder) { + var fieldSetBuilder = new SchemaInfoConfig.Schema.Fieldset.Builder(); + fieldSetBuilder.name(fieldSet.getName()); + for (String fieldName : fieldSet.getFieldNames()) + fieldSetBuilder.field(fieldName); + schemaBuilder.fieldset(fieldSetBuilder); + } + private void addSummaryConfig(SchemaInfoConfig.Schema.Builder schemaBuilder) { for (var summary : summaries.asList()) { var summaryBuilder = new SchemaInfoConfig.Schema.Summaryclass.Builder(); @@ -88,6 +171,29 @@ public final class SchemaInfo extends Derived implements SchemaInfoConfig.Produc } } + /** Returns this type as a spec on the form following "field [name] type " in schemas. */ + private String toTypeSpec(DataType dataType) { + if (dataType instanceof PrimitiveDataType) + return dataType.getName(); + if (dataType instanceof AnnotationReferenceDataType annotationType) + return "annotationreference<" + annotationType.getAnnotationType().getName() + ">"; + if (dataType instanceof ArrayDataType arrayType) + return "array<" + toTypeSpec(arrayType.getNestedType()) + ">"; + if (dataType instanceof MapDataType mapType) + return "map<" + toTypeSpec(mapType.getKeyType()) + "," + toTypeSpec(mapType.getValueType()) + ">"; + if (dataType instanceof ReferenceDataType referenceType) + return "reference<" + toTypeSpec(referenceType.getTargetType()) + ">"; + if (dataType instanceof NewDocumentReferenceDataType referenceType) + return "reference<" + toTypeSpec(referenceType.getTargetType()) + ">"; + if (dataType instanceof StructuredDataType structType) + return structType.getName(); + if (dataType instanceof TensorDataType tensorType) + return tensorType.getTensorType().toString(); + if (dataType instanceof WeightedSetDataType weightedSetDataType) + return "weightedset<" + toTypeSpec(weightedSetDataType.getNestedType()) + ">"; + throw new IllegalArgumentException("Unknown data type " + dataType + " class " + dataType.getClass()); + } + /** A store of a *small* (in memory) amount of rank profile info. */ public static final class RankProfileInfo { diff --git a/config-model/src/main/java/com/yahoo/schema/document/SDDocumentType.java b/config-model/src/main/java/com/yahoo/schema/document/SDDocumentType.java index 919a6023151..5ffe4ec533c 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/SDDocumentType.java +++ b/config-model/src/main/java/com/yahoo/schema/document/SDDocumentType.java @@ -216,7 +216,7 @@ public class SDDocumentType implements Cloneable { return f; } - public void addField(Field field) { + public Field addField(Field field) { verifyInheritance(field); for (Iterator<Field> i = docType.fieldIteratorThisTypeOnly(); i.hasNext(); ) { if (field.getName().equalsIgnoreCase((i.next()).getName())) { @@ -224,6 +224,7 @@ public class SDDocumentType implements Cloneable { } } docType.addField(field); + return field; } /** Parse-time inheritance check. */ diff --git a/config-model/src/main/java/com/yahoo/schema/document/SDField.java b/config-model/src/main/java/com/yahoo/schema/document/SDField.java index 4eaa3e05047..7821c101880 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/SDField.java +++ b/config-model/src/main/java/com/yahoo/schema/document/SDField.java @@ -556,8 +556,9 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { } /** Adds an explicit index defined in this field */ - public void addIndex(Index index) { - indices.put(index.getName(),index); + public Index addIndex(Index index) { + indices.put(index.getName(), index); + return index; } /** @@ -624,13 +625,14 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { return attributes.get(getName()); } - public void addAttribute(Attribute attribute) { + public Attribute addAttribute(Attribute attribute) { String name = attribute.getName(); if (name == null || "".equals(name)) { name = getName(); attribute.setName(name); } attributes.put(attribute.getName(),attribute); + return attribute; } /** diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/DataplaneProxy.java b/config-model/src/main/java/com/yahoo/vespa/model/container/DataplaneProxy.java index 3349aee9f2a..fe7d9581e46 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/DataplaneProxy.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/DataplaneProxy.java @@ -10,16 +10,12 @@ public class DataplaneProxy extends SimpleComponent implements DataplaneProxyCon private final Integer port; private final String serverCertificate; private final String serverKey; - private final String mTlsEndpoint; - private final String tokenEndpoint; - public DataplaneProxy(Integer port, String serverCertificate, String serverKey, String mTlsEndpoint, String tokenEndpoint) { + public DataplaneProxy(Integer port, String serverCertificate, String serverKey) { super(DataplaneProxyConfigurator.class.getName()); this.port = port; this.serverCertificate = serverCertificate; this.serverKey = serverKey; - this.mTlsEndpoint = mTlsEndpoint; - this.tokenEndpoint = tokenEndpoint; } @Override @@ -27,8 +23,6 @@ public class DataplaneProxy extends SimpleComponent implements DataplaneProxyCon builder.port(port); builder.serverCertificate(serverCertificate); builder.serverKey(serverKey); - builder.mTlsEndpoint(mTlsEndpoint); - builder.tokenEndpoint(tokenEndpoint); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/PageTemplates.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/PageTemplates.java index dc9a9f127ed..d186008b998 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/PageTemplates.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/PageTemplates.java @@ -20,11 +20,8 @@ import java.util.List; */ public class PageTemplates implements Serializable, PageTemplatesConfig.Producer { - private List<String> pages = new ArrayList<>(); + private final List<String> pages = new ArrayList<>(); - /** The number of pages in this, for reporting */ - //private int pages=0; - /** Validates page templates in an application package. The passed readers will be closed. */ public static void validate(ApplicationPackage applicationPackage) { List<NamedReader> pageTemplateFiles=null; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QrsCache.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/QrsCache.java deleted file mode 100644 index 64b3e67b616..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QrsCache.java +++ /dev/null @@ -1,17 +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.container.search; - -/** - * A helper class to wrap a set of QRS cache settings. - * - * @author Steinar Knutsen - */ -public class QrsCache { - - public final Integer size; - - public QrsCache(Integer size) { - this.size = size; - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/RankProfilesEvaluatorComponent.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/RankProfilesEvaluatorComponent.java index 75a2802ee53..47ed2ea99f7 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/RankProfilesEvaluatorComponent.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/RankProfilesEvaluatorComponent.java @@ -8,7 +8,6 @@ import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.vespa.config.search.core.OnnxModelsConfig; import com.yahoo.vespa.config.search.core.RankingConstantsConfig; import com.yahoo.vespa.config.search.core.RankingExpressionsConfig; -import com.yahoo.vespa.model.container.ContainerModelEvaluation; import com.yahoo.vespa.model.container.PlatformBundles; import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.search.DocumentDatabase; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/SemanticRuleBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/SemanticRuleBuilder.java deleted file mode 100644 index 4923c41224e..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/SemanticRuleBuilder.java +++ /dev/null @@ -1,87 +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.container.search; - -import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.io.IOUtils; -import com.yahoo.io.reader.NamedReader; -import com.yahoo.language.simple.SimpleLinguistics; -import com.yahoo.prelude.semantics.RuleBase; -import com.yahoo.prelude.semantics.RuleImporter; -import com.yahoo.prelude.semantics.SemanticRulesConfig; -import com.yahoo.prelude.semantics.parser.ParseException; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Reads the semantic rules from the application package by delegating to SemanticRules. - * - * @author bratseth - */ -// TODO: Move into SemanticRules -public class SemanticRuleBuilder { - - /** Builds the semantic rules for an application package and validates them */ - public SemanticRules build(ApplicationPackage applicationPackage) { - var ruleFiles = applicationPackage.getFiles(ApplicationPackage.RULES_DIR, "sr"); - var rules = new SemanticRules(ruleFiles.stream().map(this::toRuleBaseConfigView).toList()); - - // Create config to make sure rules are valid, config is validated in call to toMap() below - var builder = new SemanticRulesConfig.Builder(); - rules.getConfig(builder); - SemanticRulesConfig config = builder.build(); - try { - toMap(config); // validates config - ensureZeroOrOneDefaultRule(config); - } catch (ParseException | IOException e) { - throw new RuntimeException(e); - } - return rules; - } - - private SemanticRules.RuleBase toRuleBaseConfigView(NamedReader reader) { - try { - String ruleBaseString = IOUtils.readAll(reader.getReader()); - boolean isDefault = ruleBaseString.contains("@default"); - return new SemanticRules.RuleBase(toName(reader.getName()), isDefault, ruleBaseString); - } - catch (IOException e) { - throw new IllegalArgumentException("Could not load rules bases", e); - } - } - - private String toName(String fileName) { - String shortName = new File(fileName).getName(); - return shortName.substring(0, shortName.length() - ".sr".length()); - } - - private void ensureZeroOrOneDefaultRule(SemanticRulesConfig config) { - String defaultName = null; - for (SemanticRulesConfig.Rulebase ruleBase : config.rulebase()) { - if (defaultName != null && ruleBase.isdefault()) { - List<String> defaultRules = new ArrayList<>(List.of(defaultName, ruleBase.name())); - defaultRules.sort(String::compareTo); - throw new IllegalArgumentException("Rules " + defaultRules + " are both marked as the default rule, there can only be one"); - } - if (ruleBase.isdefault()) - defaultName = ruleBase.name(); - } - } - - static Map<String, RuleBase> toMap(SemanticRulesConfig config) throws ParseException, IOException { - RuleImporter ruleImporter = new RuleImporter(config, true, new SimpleLinguistics()); - Map<String, RuleBase> ruleBaseMap = new HashMap<>(); - for (SemanticRulesConfig.Rulebase ruleBaseConfig : config.rulebase()) { - RuleBase ruleBase = ruleImporter.importConfig(ruleBaseConfig); - if (ruleBaseConfig.isdefault()) - ruleBase.setDefault(true); - ruleBaseMap.put(ruleBase.getName(), ruleBase); - } - return ruleBaseMap; - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/SemanticRules.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/SemanticRules.java index 0083fc6b886..a77c2c98380 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/SemanticRules.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/SemanticRules.java @@ -1,9 +1,21 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.search; +import com.yahoo.config.application.api.ApplicationPackage; +import com.yahoo.io.IOUtils; +import com.yahoo.io.reader.NamedReader; +import com.yahoo.language.simple.SimpleLinguistics; +import com.yahoo.prelude.semantics.RuleImporter; import com.yahoo.prelude.semantics.SemanticRulesConfig; +import com.yahoo.prelude.semantics.parser.ParseException; + +import java.io.File; +import java.io.IOException; import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Returns the semantic rules config from a set of rule bases. @@ -48,4 +60,67 @@ public class SemanticRules implements Serializable, SemanticRulesConfig.Producer } + public static class SemanticRuleBuilder { + + /** Builds the semantic rules for an application package and validates them */ + public SemanticRules build(ApplicationPackage applicationPackage) { + var ruleFiles = applicationPackage.getFiles(ApplicationPackage.RULES_DIR, "sr"); + var rules = new SemanticRules(ruleFiles.stream().map(this::toRuleBaseConfigView).toList()); + + // Create config to make sure rules are valid, config is validated in call to toMap() below + var builder = new SemanticRulesConfig.Builder(); + rules.getConfig(builder); + SemanticRulesConfig config = builder.build(); + try { + toMap(config); // validates config + ensureZeroOrOneDefaultRule(config); + } catch (ParseException | IOException e) { + throw new RuntimeException(e); + } + return rules; + } + + private RuleBase toRuleBaseConfigView(NamedReader reader) { + try { + String ruleBaseString = IOUtils.readAll(reader.getReader()); + boolean isDefault = ruleBaseString.contains("@default"); + return new RuleBase(toName(reader.getName()), isDefault, ruleBaseString); + } + catch (IOException e) { + throw new IllegalArgumentException("Could not load rules bases", e); + } + } + + private String toName(String fileName) { + String shortName = new File(fileName).getName(); + return shortName.substring(0, shortName.length() - ".sr".length()); + } + + private void ensureZeroOrOneDefaultRule(SemanticRulesConfig config) { + String defaultName = null; + for (SemanticRulesConfig.Rulebase ruleBase : config.rulebase()) { + if (defaultName != null && ruleBase.isdefault()) { + List<String> defaultRules = new ArrayList<>(List.of(defaultName, ruleBase.name())); + defaultRules.sort(String::compareTo); + throw new IllegalArgumentException("Rules " + defaultRules + " are both marked as the default rule, there can only be one"); + } + if (ruleBase.isdefault()) + defaultName = ruleBase.name(); + } + } + + static Map<String, com.yahoo.prelude.semantics.RuleBase> toMap(SemanticRulesConfig config) throws ParseException, IOException { + RuleImporter ruleImporter = new RuleImporter(config, true, new SimpleLinguistics()); + Map<String, com.yahoo.prelude.semantics.RuleBase> ruleBaseMap = new HashMap<>(); + for (SemanticRulesConfig.Rulebase ruleBaseConfig : config.rulebase()) { + com.yahoo.prelude.semantics.RuleBase ruleBase = ruleImporter.importConfig(ruleBaseConfig); + if (ruleBaseConfig.isdefault()) + ruleBase.setDefault(true); + ruleBaseMap.put(ruleBase.getName(), ruleBase); + } + return ruleBaseMap; + } + + } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index f795dc4bd93..9fda25bcb00 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -602,19 +602,11 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { cluster.addSimpleComponent(DataplaneProxyCredentials.class); cluster.addSimpleComponent(DataplaneProxyService.class); - var mTlsEndpoint = cluster.endpoints() - .stream() - .filter(endpoint -> endpoint.scope().equals(ApplicationClusterEndpoint.Scope.zone)) - .findFirst() - .map(endpoint -> endpoint.dnsName().value()) - .orElseThrow(); var dataplaneProxy = new DataplaneProxy( getDataplanePort(deployState), endpointCertificateSecrets.certificate(), - endpointCertificateSecrets.key(), - mTlsEndpoint, - "token." + mTlsEndpoint); + endpointCertificateSecrets.key()); cluster.addComponent(dataplaneProxy); } connectorFactory = authorizeClient 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 080a2ca43dc..960850def1f 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 @@ -43,7 +43,7 @@ public class IndexedSearchCluster extends SearchCluster DispatchNodesConfig.Producer, ConfigInstance.Producer { - private IndexingDocproc indexingDocproc; + private final IndexingDocproc indexingDocproc; private Tuning tuning; private SearchCoverage searchCoverage; diff --git a/config-model/src/test/derived/imported_position_field_summary/schema-info.cfg b/config-model/src/test/derived/imported_position_field_summary/schema-info.cfg index e4bd88e6ac9..f820ad9720b 100644 --- a/config-model/src/test/derived/imported_position_field_summary/schema-info.cfg +++ b/config-model/src/test/derived/imported_position_field_summary/schema-info.cfg @@ -1,4 +1,22 @@ schema[].name "child" +schema[].field[].name "parent_ref" +schema[].field[].type "reference<parent>" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "my_pos_zcurve" +schema[].field[].type "long" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "pos_zcurve" +schema[].field[].type "long" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "my_pos" +schema[].field[].type "position" +schema[].field[].attribute false +schema[].field[].index false +schema[].fieldset[].name "[document]" +schema[].fieldset[].field[] "parent_ref" schema[].summaryclass[].name "default" schema[].summaryclass[].fields[].name "parent_ref" schema[].summaryclass[].fields[].type "longstring" diff --git a/config-model/src/test/derived/neuralnet_noqueryprofile/schema-info.cfg b/config-model/src/test/derived/neuralnet_noqueryprofile/schema-info.cfg index 82bba81f0d5..728856abbf2 100644 --- a/config-model/src/test/derived/neuralnet_noqueryprofile/schema-info.cfg +++ b/config-model/src/test/derived/neuralnet_noqueryprofile/schema-info.cfg @@ -1,4 +1,90 @@ schema[].name "neuralnet" +schema[].field[].name "uniqueRCount" +schema[].field[].type "double" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "pinned" +schema[].field[].type "int" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "createdAt" +schema[].field[].type "long" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "updatedAt" +schema[].field[].type "long" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "uvCount" +schema[].field[].type "int" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "dvCount" +schema[].field[].type "int" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "aVoteCount" +schema[].field[].type "int" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "rCount" +schema[].field[].type "int" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "uniqueRACount" +schema[].field[].type "int" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "rTo" +schema[].field[].type "string" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "markedAsAAt" +schema[].field[].type "long" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "normalizedTextScore" +schema[].field[].type "float" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "t" +schema[].field[].type "float" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "relevance" +schema[].field[].type "float" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "normalizedCS" +schema[].field[].type "float" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "laAt" +schema[].field[].type "long" +schema[].field[].attribute true +schema[].field[].index false +schema[].field[].name "hsScore" +schema[].field[].type "double" +schema[].field[].attribute true +schema[].field[].index false +schema[].fieldset[].name "[document]" +schema[].fieldset[].field[] "aVoteCount" +schema[].fieldset[].field[] "createdAt" +schema[].fieldset[].field[] "dvCount" +schema[].fieldset[].field[] "hsScore" +schema[].fieldset[].field[] "laAt" +schema[].fieldset[].field[] "markedAsAAt" +schema[].fieldset[].field[] "normalizedCS" +schema[].fieldset[].field[] "normalizedTextScore" +schema[].fieldset[].field[] "pinned" +schema[].fieldset[].field[] "rCount" +schema[].fieldset[].field[] "rTo" +schema[].fieldset[].field[] "relevance" +schema[].fieldset[].field[] "t" +schema[].fieldset[].field[] "uniqueRACount" +schema[].fieldset[].field[] "uniqueRCount" +schema[].fieldset[].field[] "updatedAt" +schema[].fieldset[].field[] "uvCount" schema[].summaryclass[].name "default" schema[].summaryclass[].fields[].name "rankfeatures" schema[].summaryclass[].fields[].type "featuredata" diff --git a/config-model/src/test/derived/rankprofilemodularity/schema-info.cfg b/config-model/src/test/derived/rankprofilemodularity/schema-info.cfg index 86cbfa0562d..377c10d3293 100644 --- a/config-model/src/test/derived/rankprofilemodularity/schema-info.cfg +++ b/config-model/src/test/derived/rankprofilemodularity/schema-info.cfg @@ -1,4 +1,10 @@ schema[].name "test" +schema[].field[].name "title" +schema[].field[].type "string" +schema[].field[].attribute false +schema[].field[].index true +schema[].fieldset[].name "[document]" +schema[].fieldset[].field[] "title" schema[].summaryclass[].name "default" schema[].summaryclass[].fields[].name "rankfeatures" schema[].summaryclass[].fields[].type "featuredata" diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/SemanticRulesTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/SemanticRulesTest.java index da6e055724a..544acc81b8d 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/SemanticRulesTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/SemanticRulesTest.java @@ -11,6 +11,7 @@ import java.io.File; import java.io.IOException; import java.util.Map; +import static com.yahoo.vespa.model.container.search.SemanticRules.SemanticRuleBuilder; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java index 622fcfdf4fd..3b3fe196cad 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java @@ -1,6 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.search.test; +import com.yahoo.document.DataType; +import com.yahoo.schema.Index; +import com.yahoo.schema.document.Attribute; +import com.yahoo.schema.document.SDField; import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.vespa.model.VespaModel; @@ -13,10 +17,116 @@ import static org.junit.jupiter.api.Assertions.fail; public class SchemaInfoTestCase { + @Test + void testFieldWithAliasExporting() { + var schemaInfoTester = new SchemaInfoTester(); + var schema = schemaInfoTester.createSchema("test"); + var field = (SDField)schema.getDocument().addField(new SDField("f1", DataType.STRING)); + field.getAliasToName().put("alias1", "f1"); + field.getAliasToName().put("alias2", "f1"); + assertEquals(""" + schema[0].name "test" + schema[0].field[0].name "f1" + schema[0].field[0].type "string" + schema[0].field[0].alias[0] "alias1" + schema[0].field[0].alias[1] "alias2" + schema[0].field[0].attribute false + schema[0].field[0].index false + schema[0].summaryclass[0].name "default" + schema[0].summaryclass[0].fields[0].name "documentid" + schema[0].summaryclass[0].fields[0].type "longstring" + schema[0].summaryclass[0].fields[0].dynamic false""", + schemaInfoTester.schemaInfoConfig(schema)); + } + + @Test + void testFieldsetExporting() { + var schemaInfoTester = new SchemaInfoTester(); + var schema = schemaInfoTester.createSchema("test"); + schema.getDocument().addField(new SDField("f1", DataType.STRING)); + schema.getDocument().addField(new SDField("f2", DataType.STRING)); + schema.fieldSets().addUserFieldSetItem("fs1", "f1"); + schema.fieldSets().addUserFieldSetItem("fs1", "f2"); + schema.fieldSets().addUserFieldSetItem("fs2", "f1"); + assertEquals(""" + schema[0].name "test" + schema[0].field[0].name "f1" + schema[0].field[0].type "string" + schema[0].field[0].attribute false + schema[0].field[0].index false + schema[0].field[1].name "f2" + schema[0].field[1].type "string" + schema[0].field[1].attribute false + schema[0].field[1].index false + schema[0].fieldset[0].name "fs1" + schema[0].fieldset[0].field[0] "f1" + schema[0].fieldset[0].field[1] "f2" + schema[0].fieldset[1].name "fs2" + schema[0].fieldset[1].field[0] "f1" + schema[0].summaryclass[0].name "default" + schema[0].summaryclass[0].fields[0].name "documentid" + schema[0].summaryclass[0].fields[0].type "longstring" + schema[0].summaryclass[0].fields[0].dynamic false""", + schemaInfoTester.schemaInfoConfig(schema)); + } + + @Test + void testFieldWithIndexExporting() { + var schemaInfoTester = new SchemaInfoTester(); + var schema = schemaInfoTester.createSchema("test"); + var field = (SDField)schema.getDocument().addField(new SDField("f1", DataType.STRING)); + var index = field.addIndex(new Index("f1Index")); + index.addAlias("a1"); + index.addAlias("a2"); + assertEquals(""" + schema[0].name "test" + schema[0].field[0].name "f1" + schema[0].field[0].type "string" + schema[0].field[0].attribute false + schema[0].field[0].index false + schema[0].field[1].name "f1Index" + schema[0].field[1].type "string" + schema[0].field[1].alias[0] "a1" + schema[0].field[1].alias[1] "a2" + schema[0].field[1].attribute false + schema[0].field[1].index true + schema[0].summaryclass[0].name "default" + schema[0].summaryclass[0].fields[0].name "documentid" + schema[0].summaryclass[0].fields[0].type "longstring" + schema[0].summaryclass[0].fields[0].dynamic false""", + schemaInfoTester.schemaInfoConfig(schema)); + } + + @Test + void testFieldWithAttributeExporting() { + var schemaInfoTester = new SchemaInfoTester(); + var schema = schemaInfoTester.createSchema("test"); + var field = (SDField)schema.getDocument().addField(new SDField("f1", DataType.STRING)); + var attribute = field.addAttribute(new Attribute("f1Attribute", field.getDataType())); + attribute.getAliases().add("a1"); + attribute.getAliases().add("a2"); + assertEquals(""" + schema[0].name "test" + schema[0].field[0].name "f1" + schema[0].field[0].type "string" + schema[0].field[0].attribute false + schema[0].field[0].index false + schema[0].field[1].name "f1Attribute" + schema[0].field[1].type "string" + schema[0].field[1].alias[0] "a1" + schema[0].field[1].alias[1] "a2" + schema[0].field[1].attribute true + schema[0].field[1].index false + schema[0].summaryclass[0].name "default" + schema[0].summaryclass[0].fields[0].name "documentid" + schema[0].summaryclass[0].fields[0].type "longstring" + schema[0].summaryclass[0].fields[0].dynamic false""", + schemaInfoTester.schemaInfoConfig(schema)); + } + /** Schema-info should contain all schemas, independent of clusters. */ @Test void requireThatSchemaInfoIsAvailable() { - List.of(1.0, 2.0, 3.0).toArray(new Double[3]); String inputs = " rank-profile inputs {" + " inputs {" + diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTester.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTester.java new file mode 100644 index 00000000000..b8bb83540d4 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTester.java @@ -0,0 +1,36 @@ +package com.yahoo.vespa.model.search.test; + +import com.yahoo.config.model.deploy.TestProperties; +import com.yahoo.document.DataType; +import com.yahoo.schema.RankProfileRegistry; +import com.yahoo.schema.Schema; +import com.yahoo.schema.derived.SchemaInfo; +import com.yahoo.schema.derived.Summaries; +import com.yahoo.schema.document.SDDocumentType; +import com.yahoo.schema.document.SDField; +import com.yahoo.search.config.SchemaInfoConfig; +import com.yahoo.vespa.documentmodel.DocumentSummary; +import com.yahoo.vespa.model.test.utils.DeployLoggerStub; + +/** + * @author bratseth + */ +public class SchemaInfoTester { + + public Schema createSchema(String name) { + var schema = new Schema(name, null); + var document = new SDDocumentType(name); + schema.addDocument(document); + schema.addSummary(new DocumentSummary("default", schema)); + return schema; + } + + public String schemaInfoConfig(Schema schema) { + var schemaInfo = new SchemaInfo(schema, new RankProfileRegistry(), new Summaries(schema, new DeployLoggerStub(), new TestProperties())); + var schemaInfoConfigBuilder = new SchemaInfoConfig.Builder(); + schemaInfo.getConfig(schemaInfoConfigBuilder); + var schemaInfoConfig = schemaInfoConfigBuilder.build(); + return schemaInfoConfig.toString(); + } + +} |