diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-01-24 17:01:31 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-01-24 17:01:31 +0100 |
commit | 56748bee37ad8fae2889c2f7711201768f8be342 (patch) | |
tree | 07e584cab754483d2434fed40a3cc3d763c93f5c /config-model | |
parent | a1126b2641c29e7cf0d567edec6fc43c60e1f942 (diff) |
Simplify
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/Application.java | 10 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Application.java b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java index ace0bdca590..fe29c9cf313 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Application.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java @@ -3,9 +3,11 @@ package com.yahoo.searchdefinition; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.vespa.documentmodel.DocumentModel; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; /** @@ -19,6 +21,7 @@ public class Application { private final ApplicationPackage applicationPackage; private final Map<String, Schema> schemas = new LinkedHashMap<>(); + private final DocumentModel documentModel = new DocumentModel(); public Application(ApplicationPackage applicationPackage) { this.applicationPackage = applicationPackage; @@ -35,6 +38,13 @@ public class Application { /** Returns an unmodifiable list of the schemas of this application */ public Map<String, Schema> schemas() { return Collections.unmodifiableMap(schemas); } + public void buildDocumentModel(List<Schema> schemasSomewhatOrdered) { + var builder = new DocumentModelBuilder(documentModel); + builder.addToModel(schemasSomewhatOrdered); + } + + public DocumentModel documentModel() { return documentModel; } + /** Validates this. Must be called after all content is added to it. */ public void validate(DeployLogger logger) { schemas.values().forEach(schema -> schema.validate(logger)); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java index c5811b8a603..8b22612108f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java @@ -49,7 +49,6 @@ import java.util.Set; public class SchemaBuilder { private final DocumentTypeManager docTypeMgr = new DocumentTypeManager(); - private final DocumentModel model = new DocumentModel(); private final Application application; private final RankProfileRegistry rankProfileRegistry; private final QueryProfileRegistry queryProfileRegistry; @@ -272,13 +271,12 @@ public class SchemaBuilder { if (validate) new DocumentGraphValidator().validateDocumentGraph(sdocs); - var builder = new DocumentModelBuilder(model); List<Schema> schemasSomewhatOrdered = new ArrayList<>(application.schemas().values()); for (Schema schema : new SearchOrderer().order(schemasSomewhatOrdered)) { new FieldOperationApplierForSearch().process(schema); // TODO: Why is this not in the regular list? process(schema, new QueryProfiles(queryProfileRegistry, deployLogger), validate); } - builder.addToModel(schemasSomewhatOrdered); + application.buildDocumentModel(schemasSomewhatOrdered); isBuilt = true; } @@ -312,9 +310,7 @@ public class SchemaBuilder { return application.schemas().values().stream().findAny().get(); } - public DocumentModel getModel() { - return model; - } + public DocumentModel getModel() { return application.documentModel(); } /** * Returns the built {@link Schema} object that has the given name. If the name is unknown, this method will simply |