diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-03-14 13:39:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-14 13:39:25 +0100 |
commit | 2d415aed93581592feaf14f8774120319b90c677 (patch) | |
tree | 0f1b76ab8cf342191bf3b1b247c35f6aa8def228 /config-model/src/main/java/com/yahoo | |
parent | 6c76d7dfcf6df3e1f92034d114b55425071faef8 (diff) | |
parent | 1fe5d1e05cce1dbb712f74b13731eb56a4be1b0d (diff) |
Merge pull request #30626 from vespa-engine/balder/index-mode-in-schema
Add index mode to Schema
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
5 files changed, 33 insertions, 12 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java b/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java index b35918b3460..421f3d5a1d1 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java @@ -28,7 +28,7 @@ import java.io.Writer; public class DerivedConfiguration { private final Schema schema; - private final boolean isStreaming; + private final SchemaInfo.IndexMode indexMode; private Summaries summaries; private Juniperrc juniperrc; private AttributeFields attributeFields; @@ -57,7 +57,8 @@ public class DerivedConfiguration { } DerivedConfiguration(Schema schema, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles) { - this(schema, new DeployState.Builder().rankProfileRegistry(rankProfileRegistry).queryProfiles(queryProfiles).build(), false); + this(new DeployState.Builder().rankProfileRegistry(rankProfileRegistry).queryProfiles(queryProfiles).build(), + schema, SchemaInfo.IndexMode.INDEX); } /** @@ -67,8 +68,8 @@ public class DerivedConfiguration { * argument is live. Which means that this object will be inconsistent if the given * schema is later modified. */ - public DerivedConfiguration(Schema schema, DeployState deployState, boolean isStreaming) { - this.isStreaming = isStreaming; + public DerivedConfiguration(DeployState deployState, Schema schema, SchemaInfo.IndexMode indexMode) { + this.indexMode = indexMode; try { Validator.ensureNotNull("Schema", schema); this.schema = schema; @@ -81,9 +82,9 @@ public class DerivedConfiguration { summaries = new Summaries(schema, deployState.getDeployLogger(), deployState.getProperties().featureFlags()); juniperrc = new Juniperrc(schema); rankProfileList = new RankProfileList(schema, schema.rankExpressionFiles(), attributeFields, deployState); - indexingScript = new IndexingScript(schema, isStreaming); - indexInfo = new IndexInfo(schema, isStreaming); - schemaInfo = new SchemaInfo(schema, deployState.rankProfileRegistry(), summaries); + indexingScript = new IndexingScript(schema, isStreaming()); + indexInfo = new IndexInfo(schema, isStreaming()); + schemaInfo = new SchemaInfo(schema, indexMode, deployState.rankProfileRegistry(), summaries); indexSchema = new IndexSchema(schema); importedFields = new ImportedFields(schema); } @@ -153,7 +154,7 @@ public class DerivedConfiguration { } public boolean isStreaming() { - return isStreaming; + return indexMode == SchemaInfo.IndexMode.STREAMING; } public Summaries getSummaries() { 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 19a045ac444..f996b2624db 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 @@ -42,13 +42,32 @@ public final class SchemaInfo extends Derived { private final Map<String, RankProfileInfo> rankProfiles; private final Summaries summaries; + private final IndexMode indexMode; - public SchemaInfo(Schema schema, RankProfileRegistry rankProfileRegistry, Summaries summaries) { + public enum IndexMode {INDEX, STREAMING, STORE_ONLY} + + public SchemaInfo(Schema schema, String indexMode, RankProfileRegistry rankProfileRegistry, Summaries summaries) { + this(schema, indexMode(indexMode), rankProfileRegistry, summaries); + } + public SchemaInfo(Schema schema, IndexMode indexMode, RankProfileRegistry rankProfileRegistry, Summaries summaries) { this.schema = schema; this.rankProfiles = Collections.unmodifiableMap(toRankProfiles(rankProfileRegistry.rankProfilesOf(schema))); this.summaries = summaries; + this.indexMode = indexMode; } + private static IndexMode indexMode(String mode) { + if (mode == null) return IndexMode.INDEX; + return switch (mode) { + case "index" -> IndexMode.INDEX; + case "streaming" -> IndexMode.STREAMING; + case "store-only" -> IndexMode.STORE_ONLY; + default -> IndexMode.STORE_ONLY; + }; + } + + public IndexMode getIndexMode() { return indexMode; } + public String name() { return schema.getName(); } @Override 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 125d3b10512..91a5716b0f8 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 @@ -258,7 +258,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> throw new IllegalArgumentException("Schema '" + schemaDefinitionXMLHandler.getName() + "' referenced in " + this + " does not exist"); - sc.add(new SchemaInfo(schema, deployState.rankProfileRegistry(), null)); + sc.add(new SchemaInfo(schema, e.stringAttribute("mode"), deployState.rankProfileRegistry(), null)); } } 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 b51185ddac2..4a37b27d1c7 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 @@ -65,7 +65,7 @@ public class IndexedSearchCluster extends SearchCluster implements for (SchemaInfo spec : schemas().values()) { if (spec.fullSchema() instanceof DocumentOnlySchema) continue; var db = new DocumentDatabase(this, spec.fullSchema().getName(), - new DerivedConfiguration(spec.fullSchema(), deployState, false)); + new DerivedConfiguration(deployState, spec.fullSchema(), spec.getIndexMode())); add(db); } } 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 3f15bc90b8f..e188a086614 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 @@ -7,6 +7,7 @@ import com.yahoo.config.model.producer.TreeConfigProducer; import com.yahoo.schema.Schema; import com.yahoo.schema.derived.AttributeFields; import com.yahoo.schema.derived.DerivedConfiguration; +import com.yahoo.schema.derived.SchemaInfo; import com.yahoo.vespa.config.search.AttributesConfig; import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.vespa.config.search.SummaryConfig; @@ -64,7 +65,7 @@ public class StreamingSearchCluster extends SearchCluster implements if ( ! schema.getName().equals(docTypeName)) throw new IllegalArgumentException("Document type name '" + docTypeName + "' must be the same as the schema name '" + schema.getName() + "'"); - add(new DocumentDatabase(this, docTypeName, new DerivedConfiguration(schema, deployState, true))); + add(new DocumentDatabase(this, docTypeName, new DerivedConfiguration(deployState, schema, SchemaInfo.IndexMode.STREAMING))); } protected void fillDocumentDBConfig(DocumentDatabase sdoc, ProtonConfig.Documentdb.Builder ddbB) { |