diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-03-14 20:33:54 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-03-14 20:33:54 +0100 |
commit | ba0d78ec993fb19a84998d5eff25718a8b022392 (patch) | |
tree | 5974b4d5f0aaab938ed8d19e88b02cfa21d1b43a /config-model/src/main/java/com/yahoo | |
parent | a544670e6f9f9146cc9514d86a440d05d76be28b (diff) |
Only produce attributes config for the proton documentdb
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java | 10 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java | 56 |
2 files changed, 43 insertions, 23 deletions
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 4a37b27d1c7..1bb79969507 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 @@ -60,16 +60,6 @@ public class IndexedSearchCluster extends SearchCluster implements } public Tuning getTuning() { return tuning; } - @Override - public void deriveFromSchemas(DeployState deployState) { - for (SchemaInfo spec : schemas().values()) { - if (spec.fullSchema() instanceof DocumentOnlySchema) continue; - var db = new DocumentDatabase(this, spec.fullSchema().getName(), - new DerivedConfiguration(deployState, spec.fullSchema(), spec.getIndexMode())); - add(db); - } - } - public void setSearchCoverage(SearchCoverage searchCoverage) { this.searchCoverage = searchCoverage; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java index 2b37ef58f9b..383f9884666 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java @@ -3,6 +3,9 @@ package com.yahoo.vespa.model.search; import com.yahoo.config.ConfigInstance; import com.yahoo.config.model.deploy.DeployState; +import com.yahoo.schema.DocumentOnlySchema; +import com.yahoo.schema.derived.AttributeFields; +import com.yahoo.schema.derived.DerivedConfiguration; import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.schema.derived.SchemaInfo; import com.yahoo.vespa.config.search.AttributesConfig; @@ -24,6 +27,7 @@ import com.yahoo.config.model.producer.TreeConfigProducer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -45,9 +49,10 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer private Double visibilityDelay = 0.0; private final Map<String, SchemaInfo> schemas = new LinkedHashMap<>(); private final Map<String, DocumentDatabase> documentDbs = new LinkedHashMap<>(); - private final List<LegacyStreamingproxy> legacyproxy = new ArrayList<>(); + private final Map<String, AttributesProducer> documentDBProducerForStreaming = new HashMap<>(); + private final List<LegacyStreamingProxy> legacyproxy = new ArrayList<>(); - private static class LegacyStreamingproxy extends TreeConfigProducer<AnyConfigProducer> implements + private static class LegacyStreamingProxy extends TreeConfigProducer<AnyConfigProducer> implements AttributesConfig.Producer, RankProfilesConfig.Producer, RankingConstantsConfig.Producer, @@ -59,9 +64,10 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer VsmfieldsConfig.Producer { private final DocumentDatabase db; - LegacyStreamingproxy(TreeConfigProducer<AnyConfigProducer> parent, String clusterName, DocumentDatabase db) { - super(parent, "cluster." + clusterName + "." + db.getName()); - this.db = new DocumentDatabase(this, db.getName(), db.getDerivedConfiguration()); + LegacyStreamingProxy(TreeConfigProducer<AnyConfigProducer> parent, String clusterName, + String schemaName, DerivedConfiguration derived) { + super(parent, "cluster." + clusterName + "." + schemaName); + this.db = new DocumentDatabase(this, schemaName, derived); } @Override public void getConfig(SummaryConfig.Builder builder) { db.getConfig(builder); } @Override public void getConfig(AttributesConfig.Builder builder) { db.getConfig(builder); } @@ -72,7 +78,20 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer @Override public void getConfig(JuniperrcConfig.Builder builder) { db.getConfig(builder); } @Override public void getConfig(VsmfieldsConfig.Builder builder) { db.getConfig(builder); } @Override public void getConfig(VsmsummaryConfig.Builder builder) { db.getConfig(builder); } + } + + private static class AttributesProducer extends AnyConfigProducer implements AttributesConfig.Producer { + private final DerivedConfiguration derived; + + AttributesProducer(TreeConfigProducer<AnyConfigProducer> parent, String docType, DerivedConfiguration derived) { + super(parent, docType); + this.derived = derived; + } + @Override + public void getConfig(AttributesConfig.Builder builder) { + derived.getConfig(builder, AttributeFields.FieldSet.FAST_ACCESS); + } } public SearchCluster(TreeConfigProducer<?> parent, String clusterName, int index) { @@ -86,12 +105,6 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer public void add(SchemaInfo schema) { schemas.put(schema.name(), schema); } - public void add(DocumentDatabase db) { - if (db.getDerivedConfiguration().isStreaming()) { - legacyproxy.add(new LegacyStreamingproxy((TreeConfigProducer<AnyConfigProducer>) getParent(), clusterName, db)); - } - documentDbs.put(db.getName(), db); - } public boolean hasDocumentDB(String name) { return documentDbs.containsKey(name); @@ -113,7 +126,19 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer * Derives the schemas from the application package. * Also stores the document names contained in the schemas. */ - public abstract void deriveFromSchemas(DeployState deployState); + public void deriveFromSchemas(DeployState deployState) { + for (SchemaInfo spec : schemas().values()) { + if (spec.fullSchema() instanceof DocumentOnlySchema) continue; // TODO verify if this special handling is necessary + String schemaName = spec.fullSchema().getName(); + var derived = new DerivedConfiguration(deployState, spec.fullSchema(), spec.getIndexMode()); + documentDbs.put(schemaName, new DocumentDatabase(this, schemaName, derived)); + if (spec.getIndexMode() == SchemaInfo.IndexMode.STREAMING) { + var parent = (TreeConfigProducer<AnyConfigProducer>)getParent(); + documentDBProducerForStreaming.put(schemaName, new AttributesProducer(parent, schemaName, derived)); + legacyproxy.add(new LegacyStreamingProxy(parent, clusterName, schemaName, derived)); + } + } + } /** Returns the document databases contained in this cluster */ public List<DocumentDatabase> getDocumentDbs() { @@ -141,7 +166,12 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer public void fillDocumentDBConfig(String documentType, ProtonConfig.Documentdb.Builder builder) { DocumentDatabase db = documentDbs.get(documentType); if (db != null) { - fillDocumentDBConfig(db, builder); + builder.inputdoctypename(documentType); + if (db.getDerivedConfiguration().isStreaming()) { + builder.configid(documentDBProducerForStreaming.get(documentType).getConfigId()); + } else { + builder.configid(db.getConfigId()); + } } } |