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 | |
parent | 1ecbb8ced4c2599155a2438625987b78e174bd5a (diff) | |
parent | 5869796c08003f41f0ac8e4738414d136b075b1d (diff) |
Merge pull request #20938 from vespa-engine/bratseth/modular-profiles
Bratseth/modular profiles
145 files changed, 1301 insertions, 1257 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java index d07df82fda1..c40ce1ebeb1 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java @@ -25,9 +25,6 @@ import java.util.jar.JarEntry; * Represents an application package, that is, used as input when creating a VespaModel and as * a general reference to all contents in an application. * - * The class hides detail as to whether the source is local files or ZooKeeper - * data in config server. - * * @author Vegard Havdal */ public interface ApplicationPackage { @@ -129,7 +126,6 @@ public interface ApplicationPackage { * Returns the files in a directory as readers. The readers <b>must</b> * be closed by the caller. * - * * @param pathFromRoot the relative path string from the root of the application package * @param suffix the suffix of files to return, or null to return all * @param recurse return files in all subdirectories (recursively) as well @@ -141,7 +137,7 @@ public interface ApplicationPackage { /** Same as getFiles(pathFromRoot, suffix, false) */ default List<NamedReader> getFiles(Path pathFromRoot, String suffix) { - return getFiles(pathFromRoot,suffix,false); + return getFiles(pathFromRoot, suffix, false); } /** Returns the major version this application is valid for, or empty if it is valid for all versions */ 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 bb8c4141873..300a77d4a6b 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 @@ -28,10 +28,10 @@ import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.config.provision.DockerImage; import com.yahoo.config.provision.Zone; import com.yahoo.io.IOUtils; -import com.yahoo.io.reader.NamedReader; +import com.yahoo.searchdefinition.Application; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SchemaBuilder; -import com.yahoo.searchdefinition.parser.ParseException; +import com.yahoo.searchdefinition.Schema; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.vespa.config.ConfigDefinition; import com.yahoo.vespa.config.ConfigDefinitionBuilder; import com.yahoo.vespa.config.ConfigDefinitionKey; @@ -40,7 +40,6 @@ 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 com.yahoo.vespa.model.search.NamedSchema; import java.io.File; import java.io.FileNotFoundException; @@ -69,7 +68,7 @@ public class DeployState implements ConfigDefinitionStore { private final DeployLogger logger; private final FileRegistry fileRegistry; private final DocumentModel documentModel; - private final List<NamedSchema> schemas; + private final List<Schema> schemas; private final ApplicationPackage applicationPackage; private final Optional<ConfigDefinitionRepo> configDefinitionRepo; private final Optional<ApplicationPackage> permanentApplicationPackage; @@ -103,8 +102,7 @@ public class DeployState implements ConfigDefinitionStore { return new Builder().applicationPackage(applicationPackage).build(); } - private DeployState(ApplicationPackage applicationPackage, - SearchDocumentModel searchDocumentModel, + private DeployState(Application application, RankProfileRegistry rankProfileRegistry, FileRegistry fileRegistry, ExecutorService executor, @@ -130,15 +128,15 @@ public class DeployState implements ConfigDefinitionStore { this.fileRegistry = fileRegistry; this.executor = executor; this.rankProfileRegistry = rankProfileRegistry; - this.applicationPackage = applicationPackage; + this.applicationPackage = application.applicationPackage(); this.properties = properties; this.vespaVersion = vespaVersion; this.previousModel = previousModel; this.accessLoggingEnabledByDefault = accessLoggingEnabledByDefault; this.provisioner = hostProvisioner.orElse(getDefaultModelHostProvisioner(applicationPackage)); this.provisioned = provisioned; - this.schemas = searchDocumentModel.getSchemas(); - this.documentModel = searchDocumentModel.getDocumentModel(); + this.schemas = List.copyOf(application.schemas().values()); + this.documentModel = application.documentModel(); this.permanentApplicationPackage = permanentApplicationPackage; this.configDefinitionRepo = configDefinitionRepo; this.endpoints = Set.copyOf(endpoints); @@ -217,7 +215,7 @@ public class DeployState implements ConfigDefinitionStore { ImportedMlModels importedModels = new ImportedMlModels(importFrom, executor, modelImporters); for (var entry : importedModels.getSkippedModels().entrySet()) { deployLogger.logApplicationPackage(Level.WARNING, "Skipping import of model " + entry.getKey() + " as an exception " + - "occurred during import. Error: " + entry.getValue()); + "occurred during import. Error: " + entry.getValue()); } return importedModels; } @@ -236,9 +234,7 @@ public class DeployState implements ConfigDefinitionStore { return applicationPackage; } - public List<NamedSchema> getSchemas() { - return schemas; - } + public List<Schema> getSchemas() { return schemas; } public DocumentModel getDocumentModel() { return documentModel; @@ -444,9 +440,10 @@ public class DeployState implements ConfigDefinitionStore { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfiles queryProfiles = new QueryProfilesBuilder().build(applicationPackage, logger); SemanticRules semanticRules = new SemanticRuleBuilder().build(applicationPackage); - SearchDocumentModel searchDocumentModel = createSearchDocumentModel(rankProfileRegistry, queryProfiles, validationParameters); - return new DeployState(applicationPackage, - searchDocumentModel, + Application application = new ApplicationBuilder(applicationPackage, fileRegistry, logger, properties, + rankProfileRegistry, queryProfiles.getRegistry()) + .build(! validationParameters.ignoreValidationErrors()); + return new DeployState(application, rankProfileRegistry, fileRegistry, executor, @@ -470,46 +467,6 @@ public class DeployState implements ConfigDefinitionStore { reindexing); } - private SearchDocumentModel createSearchDocumentModel(RankProfileRegistry rankProfileRegistry, - QueryProfiles queryProfiles, - ValidationParameters validationParameters) { - Collection<NamedReader> readers = applicationPackage.getSchemas(); - Map<String, String> names = new LinkedHashMap<>(); - SchemaBuilder builder = new SchemaBuilder(applicationPackage, fileRegistry, logger, properties, rankProfileRegistry, queryProfiles.getRegistry()); - for (NamedReader reader : readers) { - try { - String readerName = reader.getName(); - String topLevelName = builder.importReader(reader, readerName); - String sdName = stripSuffix(readerName, ApplicationPackage.SD_NAME_SUFFIX); - names.put(topLevelName, sdName); - if ( ! sdName.equals(topLevelName)) { - throw new IllegalArgumentException("Schema file name ('" + sdName + "') and name of " + - "top level element ('" + topLevelName + - "') are not equal for file '" + readerName + "'"); - } - } catch (ParseException e) { - throw new IllegalArgumentException("Could not parse schema file '" + reader.getName() + "'", e); - } catch (IOException e) { - throw new IllegalArgumentException("Could not read schema file '" + reader.getName() + "'", e); - } finally { - closeIgnoreException(reader.getReader()); - } - } - builder.build(! validationParameters.ignoreValidationErrors()); - return SearchDocumentModel.fromBuilderAndNames(builder, names); - } - - private static String stripSuffix(String nodeName, String postfix) { - assert (nodeName.endsWith(postfix)); - return nodeName.substring(0, nodeName.length() - postfix.length()); - } - - @SuppressWarnings("EmptyCatchBlock") - private static void closeIgnoreException(Reader reader) { - try { - reader.close(); - } catch(Exception e) {} - } } } diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java b/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java deleted file mode 100644 index aaba9a2b98c..00000000000 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.config.model.deploy; - -import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; -import com.yahoo.vespa.documentmodel.DocumentModel; -import com.yahoo.vespa.model.search.NamedSchema; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Internal helper class to retrieve document model and search definitions. - * - * @author Ulf Lilleengen - */ -public class SearchDocumentModel { - - private final DocumentModel documentModel; - private final List<NamedSchema> schemas; - - public SearchDocumentModel(DocumentModel documentModel, List<NamedSchema> schemas) { - this.documentModel = documentModel; - this.schemas = schemas; - - } - - public DocumentModel getDocumentModel() { - return documentModel; - } - - public List<NamedSchema> getSchemas() { - return schemas; - } - - public static SearchDocumentModel fromBuilderAndNames(SchemaBuilder builder, Map<String, String> names) { - List<NamedSchema> ret = new ArrayList<>(); - for (Schema schema : builder.getSchemaList()) { - ret.add(new NamedSchema(names.get(schema.getName()), schema)); - } - return new SearchDocumentModel(builder.getModel(), ret); - } - - public static SearchDocumentModel fromBuilder(SchemaBuilder builder) { - List<NamedSchema> ret = new ArrayList<>(); - for (Schema schema : builder.getSchemaList()) { - ret.add(new NamedSchema(schema.getName(), schema)); - } - return new SearchDocumentModel(builder.getModel(), ret); - } - -} diff --git a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java index 5822b1bca05..637bbe91e67 100644 --- a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java +++ b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java @@ -19,7 +19,7 @@ import com.yahoo.io.reader.NamedReader; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.search.query.profile.config.QueryProfileXMLReader; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.ConfigDefinitionKey; import com.yahoo.config.application.api.ApplicationPackage; @@ -33,6 +33,7 @@ import java.io.InputStream; import java.io.Reader; import java.io.StringReader; import java.io.UncheckedIOException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -95,8 +96,8 @@ public class MockApplicationPackage implements ApplicationPackage { /** Returns the root of this application package relative to the current dir */ protected File root() { return root; } + @SuppressWarnings("deprecation") // not redundant @Override - @SuppressWarnings("deprecation") // NOT redundant public String getApplicationName() { return "mock application"; } @@ -118,23 +119,26 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public List<NamedReader> getSchemas() { ArrayList<NamedReader> readers = new ArrayList<>(); - SchemaBuilder schemaBuilder = new SchemaBuilder(this, - new MockFileRegistry(), - new BaseDeployLogger(), - new TestProperties(), - new RankProfileRegistry(), - queryProfileRegistry); - for (String sd : schemas) { - try { - String name = schemaBuilder.importString(sd); - readers.add(new NamedReader(name + ApplicationPackage.SD_NAME_SUFFIX, new StringReader(sd))); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } + for (String sd : schemas) + readers.add(new NamedReader(extractSdName(sd) + ApplicationPackage.SD_NAME_SUFFIX, new StringReader(sd))); return readers; } + /** To avoid either double parsing or supplying a name explicitly */ + private String extractSdName(String sd) { + String s = sd.split("\n")[0]; + if (s.startsWith("schema")) + s = s.substring("schema".length()).trim(); + else if (s.startsWith("search")) + s = s.substring("search".length()).trim(); + else + throw new IllegalArgumentException("Expected the first line of a schema but got '" + sd + "'"); + int end = s.indexOf(' '); + if (end < 0) + end = s.indexOf('}'); + return s.substring(0, end).trim(); + } + @Override public Map<ConfigDefinitionKey, UnparsedConfigDefinition> getAllExistingConfigDefs() { return Collections.emptyMap(); @@ -142,7 +146,20 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public List<NamedReader> getFiles(Path dir, String fileSuffix, boolean recurse) { - return new ArrayList<>(); + try { + File dirFile = new File(root, dir.getName()); + if ( ! dirFile.exists()) return List.of(); + if (recurse) throw new RuntimeException("Recurse not implemented"); + List<NamedReader> readers = new ArrayList<>(); + for (var i = Files.list(dirFile.toPath()).filter(p -> p.getFileName().toString().endsWith(fileSuffix)).iterator(); i.hasNext(); ) { + var file = i.next(); + readers.add(new NamedReader(file.toString(), IOUtils.createReader(file.toString()))); + } + return readers; + } + catch (IOException e) { + throw new RuntimeException(e); + } } @Override 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 fb76c945344..2dda670f07c 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Application.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java @@ -3,10 +3,20 @@ package com.yahoo.searchdefinition; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.config.model.api.ModelContext; +import com.yahoo.searchdefinition.derived.SearchOrderer; +import com.yahoo.searchdefinition.document.SDDocumentType; +import com.yahoo.searchdefinition.processing.Processing; +import com.yahoo.searchdefinition.processing.Processor; +import com.yahoo.vespa.documentmodel.DocumentModel; +import com.yahoo.vespa.model.container.search.QueryProfiles; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; +import java.util.Set; /** * A collection of objects representing the content of an application package. @@ -18,28 +28,79 @@ import java.util.Map; public class Application { private final ApplicationPackage applicationPackage; - private final Map<String, Schema> schemas = new LinkedHashMap<>(); + private final Map<String, Schema> schemas; + private final DocumentModel documentModel; - public Application(ApplicationPackage applicationPackage) { + public Application(ApplicationPackage applicationPackage, + List<Schema> schemas, + RankProfileRegistry rankProfileRegistry, + QueryProfiles queryProfiles, + ModelContext.Properties properties, + boolean documentsOnly, + boolean validate, + Set<Class<? extends Processor>> processorsToSkip, + DeployLogger logger) { this.applicationPackage = applicationPackage; - } - public ApplicationPackage applicationPackage() { return applicationPackage; } + Map<String, Schema> schemaMap = new LinkedHashMap<>(); + for (Schema schema : schemas) { + if (schemaMap.containsKey(schema.getName())) + throw new IllegalArgumentException("Duplicate schema '" + schema.getName() + "' in " + this); + schemaMap.put(schema.getName(), schema); + } + this.schemas = Collections.unmodifiableMap(schemaMap); + + schemas.forEach(schema -> schema.setOwner(this)); + if (validate) + schemas.forEach(schema -> schema.validate(logger)); + + new TemporarySDTypeResolver(schemas, logger).process(); + + List<SDDocumentType> sdocs = new ArrayList<>(); + sdocs.add(SDDocumentType.VESPA_DOCUMENT); + for (Schema schema : schemas) { + if (schema.hasDocument()) { + sdocs.add(schema.getDocument()); + } + } + + var orderer = new SDDocumentTypeOrderer(sdocs, logger); + orderer.process(); + for (SDDocumentType sdoc : orderer.getOrdered()) { + new FieldOperationApplierForStructs().process(sdoc); + new FieldOperationApplier().process(sdoc); + } + var resolver = new DocumentReferenceResolver(schemas); + sdocs.forEach(resolver::resolveReferences); + sdocs.forEach(resolver::resolveInheritedReferences); + var importedFieldsEnumerator = new ImportedFieldsEnumerator(schemas); + sdocs.forEach(importedFieldsEnumerator::enumerateImportedFields); - public void add(Schema schema) { - if (schemas.containsKey(schema.getName())) - throw new IllegalArgumentException("Duplicate schema '" + schema.getName() + "' in " + this); - schemas.put(schema.getName(), schema); + if (validate) + new DocumentGraphValidator().validateDocumentGraph(sdocs); + + List<Schema> schemasSomewhatOrdered = new ArrayList<>(schemas); + for (Schema schema : new SearchOrderer().order(schemasSomewhatOrdered)) { + new FieldOperationApplierForSearch().process(schema); // TODO: Why is this not in the regular list? + new Processing(properties).process(schema, + logger, + rankProfileRegistry, + queryProfiles, + validate, + documentsOnly, + processorsToSkip); + } + + this.documentModel = new DocumentModelBuilder().build(schemasSomewhatOrdered); } + public ApplicationPackage applicationPackage() { return applicationPackage; } + /** Returns an unmodifiable list of the schemas of this application */ - public Map<String, Schema> schemas() { return Collections.unmodifiableMap(schemas); } + public Map<String, Schema> schemas() { return schemas; } - /** Validates this. Must be called after all content is added to it. */ - public void validate(DeployLogger logger) { - schemas.values().forEach(schema -> schema.validate(logger)); - } + public DocumentModel documentModel() { return documentModel; } @Override public String toString() { return "application " + applicationPackage.getApplicationId(); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java index 51466a5dbfa..ac4ac649a28 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java @@ -12,15 +12,13 @@ import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DocumentTypeManager; import com.yahoo.io.IOUtils; import com.yahoo.io.reader.NamedReader; +import com.yahoo.path.Path; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.search.query.profile.config.QueryProfileXMLReader; -import com.yahoo.searchdefinition.derived.SearchOrderer; -import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.searchdefinition.parser.SDParser; import com.yahoo.searchdefinition.parser.SimpleCharStream; import com.yahoo.searchdefinition.parser.TokenMgrException; -import com.yahoo.searchdefinition.processing.Processing; import com.yahoo.searchdefinition.processing.Processor; import com.yahoo.vespa.documentmodel.DocumentModel; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -28,28 +26,26 @@ import com.yahoo.yolean.Exceptions; import java.io.File; import java.io.IOException; +import java.io.Reader; import java.nio.file.Files; -import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; /** - * Helper class for building {@link Schema}s. The pattern for using this is to 1) Import - * all available search definitions, using the importXXX() methods, 2) provide the available rank types and rank - * expressions, using the setRankXXX() methods, 3) invoke the {@link #build()} method, and 4) retrieve the built - * search objects using the {@link #getSchema(String)} method. + * Application builder. Usage: + * 1) Add all schemas, using the addXXX() methods, + * 2) provide the available rank types and rank expressions, using the setRankXXX() methods, + * 3) invoke the {@link #build} method */ -// NOTE: Since this was created we have added Application, and much of the content in this should migrate there. -public class SchemaBuilder { +public class ApplicationBuilder { - private final DocumentTypeManager docTypeMgr = new DocumentTypeManager(); - private final DocumentModel model = new DocumentModel(); - private final Application application; + private final ApplicationPackage applicationPackage; + private final List<Schema> schemas = new ArrayList<>(); + private final DocumentTypeManager documentTypeManager = new DocumentTypeManager(); private final RankProfileRegistry rankProfileRegistry; private final QueryProfileRegistry queryProfileRegistry; private final FileRegistry fileRegistry; @@ -58,221 +54,230 @@ public class SchemaBuilder { /** True to build the document aspect only, skipping instantiation of rank profiles */ private final boolean documentsOnly; - private boolean isBuilt = false; + private Application application; private final Set<Class<? extends Processor>> processorsToSkip = new HashSet<>(); /** For testing only */ - public SchemaBuilder() { + public ApplicationBuilder() { this(new RankProfileRegistry(), new QueryProfileRegistry()); } /** For testing only */ - public SchemaBuilder(DeployLogger deployLogger) { + public ApplicationBuilder(DeployLogger deployLogger) { this(MockApplicationPackage.createEmpty(), deployLogger); } /** For testing only */ - public SchemaBuilder(DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { + public ApplicationBuilder(DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { this(MockApplicationPackage.createEmpty(), deployLogger, rankProfileRegistry); } /** Used for generating documents for typed access to document fields in Java */ - public SchemaBuilder(boolean documentsOnly) { + public ApplicationBuilder(boolean documentsOnly) { this(MockApplicationPackage.createEmpty(), new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry(), documentsOnly); } /** For testing only */ - public SchemaBuilder(ApplicationPackage app, DeployLogger deployLogger) { + public ApplicationBuilder(ApplicationPackage app, DeployLogger deployLogger) { this(app, new MockFileRegistry(), deployLogger, new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry()); } /** For testing only */ - public SchemaBuilder(ApplicationPackage app, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { + public ApplicationBuilder(ApplicationPackage app, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { this(app, new MockFileRegistry(), deployLogger, new TestProperties(), rankProfileRegistry, new QueryProfileRegistry()); } /** For testing only */ - public SchemaBuilder(RankProfileRegistry rankProfileRegistry) { + public ApplicationBuilder(RankProfileRegistry rankProfileRegistry) { this(rankProfileRegistry, new QueryProfileRegistry()); } /** For testing only */ - public SchemaBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { + public ApplicationBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { this(rankProfileRegistry, queryProfileRegistry, new TestProperties()); } - public SchemaBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry, ModelContext.Properties properties) { + public ApplicationBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry, ModelContext.Properties properties) { this(MockApplicationPackage.createEmpty(), new MockFileRegistry(), new BaseDeployLogger(), properties, rankProfileRegistry, queryProfileRegistry); } - public SchemaBuilder(ApplicationPackage app, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) { + public ApplicationBuilder(ApplicationPackage app, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) { this(app, fileRegistry, deployLogger, properties, rankProfileRegistry, queryProfileRegistry, false); } - private SchemaBuilder(ApplicationPackage applicationPackage, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry, - boolean documentsOnly) { - this.application = new Application(applicationPackage); + private ApplicationBuilder(ApplicationPackage applicationPackage, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry, + boolean documentsOnly) { + this.applicationPackage = applicationPackage; this.rankProfileRegistry = rankProfileRegistry; this.queryProfileRegistry = queryProfileRegistry; this.fileRegistry = fileRegistry; this.deployLogger = deployLogger; this.properties = properties; this.documentsOnly = documentsOnly; + for (NamedReader reader : applicationPackage.getSchemas()) + addSchema(reader); } /** - * Import search definition. + * Adds a schema to this application. * * @param fileName the name of the file to import * @return the name of the imported object * @throws IOException thrown if the file can not be read for some reason * @throws ParseException thrown if the file does not contain a valid search definition */ - public String importFile(String fileName) throws IOException, ParseException { + public Schema addSchemaFile(String fileName) throws IOException, ParseException { File file = new File(fileName); - return importString(IOUtils.readFile(file), file.getAbsoluteFile().getParent()); - } - - private String importFile(Path file) throws IOException, ParseException { - return importFile(file.toString()); + return addSchema(IOUtils.readFile(file), file.getAbsoluteFile().getParent()); } /** - * Reads and parses the search definition string provided by the given reader. Once all search definitions have been - * imported, call {@link #build()}. + * Reads and parses the schema string provided by the given reader. Once all schemas have been + * imported, call {@link #build}. * - * @param reader the reader whose content to import - * @param searchDefDir the path to use when resolving file references - * @return the name of the imported object - * @throws ParseException thrown if the file does not contain a valid search definition + * @param reader the reader whose content to import */ - public String importReader(NamedReader reader, String searchDefDir) throws IOException, ParseException { - return importString(IOUtils.readAll(reader), searchDefDir); + private void addSchema(NamedReader reader) { + try { + String schemaName = addSchema(IOUtils.readAll(reader), reader.getName()).getName(); + String schemaFileName = stripSuffix(reader.getName(), ApplicationPackage.SD_NAME_SUFFIX); + if ( ! schemaFileName.equals(schemaName)) { + throw new IllegalArgumentException("The file containing schema '" + schemaName + "' must be named '" + + schemaName + ApplicationPackage.SD_NAME_SUFFIX + "', not " + reader.getName()); + } + } catch (ParseException e) { + throw new IllegalArgumentException("Could not parse schema file '" + reader.getName() + "'", e); + } catch (IOException e) { + throw new IllegalArgumentException("Could not read schema file '" + reader.getName() + "'", e); + } finally { + closeIgnoreException(reader.getReader()); + } + } + + private static String stripSuffix(String readerName, String suffix) { + if ( ! readerName.endsWith(suffix)) + throw new IllegalArgumentException("Schema '" + readerName + "' does not end with " + suffix); + return readerName.substring(0, readerName.length() - suffix.length()); } /** - * Import search definition. + * Adds a schema to this application. * - * @param str the string to parse - * @return the name of the imported object + * @param string the string to parse + * @return the schema * @throws ParseException thrown if the file does not contain a valid search definition */ - public String importString(String str) throws ParseException { - return importString(str, null); + public Schema addSchema(String string) throws ParseException { + return addSchema(string, null); } - private String importString(String str, String searchDefDir) throws ParseException { - SimpleCharStream stream = new SimpleCharStream(str); - try { - return importRawSchema(new SDParser(stream, fileRegistry, deployLogger, properties, application, - rankProfileRegistry, documentsOnly) - .schema(docTypeMgr, searchDefDir)); - } catch (TokenMgrException e) { - throw new ParseException("Unknown symbol: " + e.getMessage()); - } catch (ParseException pe) { - throw new ParseException(stream.formatException(Exceptions.toMessageString(pe))); - } + private Schema addSchema(String schemaString, String schemaPath) throws ParseException { + return add(createSchema(schemaString, schemaPath)); } /** - * Registers the given schema to the application to be built during {@link #build()}. A + * Registers the given schema to the application to be built during {@link #build}. A * {@link Schema} object is considered to be "raw" if it has not already been processed. This is the case for most * programmatically constructed schemas used in unit tests. * * @param schema the object to import - * @return the name of the imported object * @throws IllegalArgumentException if the given search object has already been processed */ - public String importRawSchema(Schema schema) { + public Schema add(Schema schema) { if (schema.getName() == null) throw new IllegalArgumentException("Schema has no name"); - String rawName = schema.getName(); - application.add(schema); - return rawName; + schemas.add(schema); + return schema; } - /** - * Processes and finalizes the schemas of this. - * Only for testing. - * - * @throws IllegalStateException Thrown if this method has already been called. - */ - public void build() { - build(true); + private Schema createSchema(String schemaString, String schemaPath) throws ParseException { + Schema schema = parseSchema(schemaString, schemaPath); + addRankProfileFiles(schema, schemaPath); + return schema; } - /** - * Processes and finalizes the schemas of this. - * - * @throws IllegalStateException thrown if this method has already been called - */ - public void build(boolean validate) { - if (isBuilt) throw new IllegalStateException("Application already built"); - - new TemporarySDTypeResolver(application.schemas().values(), deployLogger).process(); + private Schema parseSchema(String schemaString, String schemaPath) throws ParseException { + SimpleCharStream stream = new SimpleCharStream(schemaString); + try { + return new SDParser(stream, applicationPackage, fileRegistry, deployLogger, properties, + rankProfileRegistry, documentsOnly) + .schema(documentTypeManager, schemaPath); + } catch (TokenMgrException e) { + throw new ParseException("Unknown symbol: " + e.getMessage()); + } catch (ParseException pe) { + throw new ParseException(stream.formatException(Exceptions.toMessageString(pe))); + } + } - if (validate) - application.validate(deployLogger); + private void addRankProfileFiles(Schema schema, String schemaPath) { + if (applicationPackage == null || schemaPath == null) return; + Path rankProfilePath = Path.fromString(schemaPath).append(schema.getName()); + System.out.println("Adding external rank profiles for " + schema + ": Have " + + applicationPackage.getFiles(rankProfilePath, ".profile").size() + + " files in " + rankProfilePath); + for (NamedReader reader : applicationPackage.getFiles(rankProfilePath, ".profile")) { + parseRankProfile(reader, schema); + } + } - List<SDDocumentType> sdocs = new ArrayList<>(); - sdocs.add(SDDocumentType.VESPA_DOCUMENT); - for (Schema schema : application.schemas().values()) { - if (schema.hasDocument()) { - sdocs.add(schema.getDocument()); + /** Parses the rank profile of the given reader and adds it to the rank profile registry for this schema. */ + private void parseRankProfile(NamedReader reader, Schema schema) { + try { + SimpleCharStream stream = new SimpleCharStream(IOUtils.readAll(reader.getReader())); + try { + new SDParser(stream, applicationPackage, fileRegistry, deployLogger, properties, + rankProfileRegistry, documentsOnly) + .rankProfile(schema); + } catch (TokenMgrException e) { + throw new ParseException("Unknown symbol: " + e.getMessage()); + } catch (ParseException pe) { + throw new ParseException(stream.formatException(Exceptions.toMessageString(pe))); } } - - var orderer = new SDDocumentTypeOrderer(sdocs, deployLogger); - orderer.process(); - for (SDDocumentType sdoc : orderer.getOrdered()) { - new FieldOperationApplierForStructs().process(sdoc); - new FieldOperationApplier().process(sdoc); + catch (IOException e) { + throw new IllegalArgumentException("Could not read rank profile " + reader.getName(), e); } - - var resolver = new DocumentReferenceResolver(application.schemas().values()); - sdocs.forEach(resolver::resolveReferences); - sdocs.forEach(resolver::resolveInheritedReferences); - var importedFieldsEnumerator = new ImportedFieldsEnumerator(application.schemas().values()); - sdocs.forEach(importedFieldsEnumerator::enumerateImportedFields); - - 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); + catch (ParseException e) { + throw new IllegalArgumentException("Could not parse rank profile " + reader.getName(), e); } - builder.addToModel(schemasSomewhatOrdered); - isBuilt = true; } - /** Returns a modifiable set of processors we should skip for these schemas. Useful for testing. */ - public Set<Class<? extends Processor>> processorsToSkip() { return processorsToSkip; } + /** - * Processes and returns the given {@link Schema} object. This method has been factored out of the {@link - * #build()} method so that subclasses can choose not to build anything. + * Processes and finalizes the schemas of this. + * + * @throws IllegalStateException thrown if this method has already been called */ - private void process(Schema schema, QueryProfiles queryProfiles, boolean validate) { - new Processing(properties).process(schema, deployLogger, - rankProfileRegistry, queryProfiles, - validate, documentsOnly, - processorsToSkip); + public Application build(boolean validate) { + if (application != null) throw new IllegalStateException("Application already built"); + + application = new Application(applicationPackage, + schemas, + rankProfileRegistry, + new QueryProfiles(queryProfileRegistry, deployLogger), + properties, + documentsOnly, + validate, + processorsToSkip, + deployLogger); + return application; } + /** Returns a modifiable set of processors we should skip for these schemas. Useful for testing. */ + public Set<Class<? extends Processor>> processorsToSkip() { return processorsToSkip; } + /** * Convenience method to call {@link #getSchema(String)} when there is only a single {@link Schema} object * built. This method will never return null. @@ -281,7 +286,7 @@ public class SchemaBuilder { * @throws IllegalStateException if there is not exactly one search. */ public Schema getSchema() { - if ( ! isBuilt) throw new IllegalStateException("Application not built."); + if (application == null) throw new IllegalStateException("Application not built"); if (application.schemas().size() != 1) throw new IllegalStateException("This call only works if we have 1 schema. Schemas: " + application.schemas().values()); @@ -289,9 +294,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 @@ -300,10 +303,10 @@ public class SchemaBuilder { * @param name the name of the schema to return, * or null to return the only one or throw an exception if there are multiple to choose from * @return the built object, or null if none with this name - * @throws IllegalStateException if {@link #build()} has not been called. + * @throws IllegalStateException if {@link #build} has not been called. */ public Schema getSchema(String name) { - if ( ! isBuilt) throw new IllegalStateException("Application not built."); + if (application == null) throw new IllegalStateException("Application not built"); if (name == null) return getSchema(); return application.schemas().get(name); } @@ -323,24 +326,24 @@ public class SchemaBuilder { * Convenience factory method to import and build a {@link Schema} object from a string. * * @param sd the string to build from - * @return the built {@link SchemaBuilder} object + * @return the built {@link ApplicationBuilder} object * @throws ParseException thrown if there is a problem parsing the string */ - public static SchemaBuilder createFromString(String sd) throws ParseException { + public static ApplicationBuilder createFromString(String sd) throws ParseException { return createFromString(sd, new BaseDeployLogger()); } - public static SchemaBuilder createFromString(String sd, DeployLogger logger) throws ParseException { - SchemaBuilder builder = new SchemaBuilder(logger); - builder.importString(sd); + public static ApplicationBuilder createFromString(String sd, DeployLogger logger) throws ParseException { + ApplicationBuilder builder = new ApplicationBuilder(logger); + builder.addSchema(sd); builder.build(true); return builder; } - public static SchemaBuilder createFromStrings(DeployLogger logger, String ... schemas) throws ParseException { - SchemaBuilder builder = new SchemaBuilder(logger); + public static ApplicationBuilder createFromStrings(DeployLogger logger, String ... schemas) throws ParseException { + ApplicationBuilder builder = new ApplicationBuilder(logger); for (var schema : schemas) - builder.importString(schema); + builder.addSchema(schema); builder.build(true); return builder; } @@ -349,26 +352,26 @@ public class SchemaBuilder { * Convenience factory method to import and build a {@link Schema} object from a file. Only for testing. * * @param fileName the file to build from - * @return the built {@link SchemaBuilder} object + * @return the built {@link ApplicationBuilder} object * @throws IOException if there was a problem reading the file. * @throws ParseException if there was a problem parsing the file content. */ - public static SchemaBuilder createFromFile(String fileName) throws IOException, ParseException { + public static ApplicationBuilder createFromFile(String fileName) throws IOException, ParseException { return createFromFile(fileName, new BaseDeployLogger()); } /** * Convenience factory methdd to create a SearchBuilder from multiple SD files. Only for testing. */ - public static SchemaBuilder createFromFiles(Collection<String> fileNames) throws IOException, ParseException { + public static ApplicationBuilder createFromFiles(Collection<String> fileNames) throws IOException, ParseException { return createFromFiles(fileNames, new BaseDeployLogger()); } - public static SchemaBuilder createFromFile(String fileName, DeployLogger logger) throws IOException, ParseException { + public static ApplicationBuilder createFromFile(String fileName, DeployLogger logger) throws IOException, ParseException { return createFromFile(fileName, logger, new RankProfileRegistry(), new QueryProfileRegistry()); } - private static SchemaBuilder createFromFiles(Collection<String> fileNames, DeployLogger logger) throws IOException, ParseException { + private static ApplicationBuilder createFromFiles(Collection<String> fileNames, DeployLogger logger) throws IOException, ParseException { return createFromFiles(fileNames, new MockFileRegistry(), logger, new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry()); } @@ -378,14 +381,14 @@ public class SchemaBuilder { * @param fileName the file to build from. * @param deployLogger logger for deploy messages. * @param rankProfileRegistry registry for rank profiles. - * @return the built {@link SchemaBuilder} object. + * @return the built {@link ApplicationBuilder} object. * @throws IOException if there was a problem reading the file. * @throws ParseException if there was a problem parsing the file content. */ - private static SchemaBuilder createFromFile(String fileName, - DeployLogger deployLogger, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryprofileRegistry) + private static ApplicationBuilder createFromFile(String fileName, + DeployLogger deployLogger, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryprofileRegistry) throws IOException, ParseException { return createFromFiles(Collections.singletonList(fileName), new MockFileRegistry(), deployLogger, new TestProperties(), rankProfileRegistry, queryprofileRegistry); @@ -394,62 +397,62 @@ public class SchemaBuilder { /** * Convenience factory methdd to create a SearchBuilder from multiple SD files.. */ - private static SchemaBuilder createFromFiles(Collection<String> fileNames, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryprofileRegistry) + private static ApplicationBuilder createFromFiles(Collection<String> fileNames, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryprofileRegistry) throws IOException, ParseException { - SchemaBuilder builder = new SchemaBuilder(MockApplicationPackage.createEmpty(), - fileRegistry, - deployLogger, - properties, - rankProfileRegistry, - queryprofileRegistry); + ApplicationBuilder builder = new ApplicationBuilder(MockApplicationPackage.createEmpty(), + fileRegistry, + deployLogger, + properties, + rankProfileRegistry, + queryprofileRegistry); for (String fileName : fileNames) { - builder.importFile(fileName); + builder.addSchemaFile(fileName); } builder.build(true); return builder; } - public static SchemaBuilder createFromDirectory(String dir, FileRegistry fileRegistry, DeployLogger logger, ModelContext.Properties properties) throws IOException, ParseException { + public static ApplicationBuilder createFromDirectory(String dir, FileRegistry fileRegistry, DeployLogger logger, ModelContext.Properties properties) throws IOException, ParseException { return createFromDirectory(dir, fileRegistry, logger, properties, new RankProfileRegistry()); } - public static SchemaBuilder createFromDirectory(String dir, - FileRegistry fileRegistry, - DeployLogger logger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry) throws IOException, ParseException { + public static ApplicationBuilder createFromDirectory(String dir, + FileRegistry fileRegistry, + DeployLogger logger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry) throws IOException, ParseException { return createFromDirectory(dir, fileRegistry, logger, properties, rankProfileRegistry, createQueryProfileRegistryFromDirectory(dir)); } - private static SchemaBuilder createFromDirectory(String dir, - FileRegistry fileRegistry, - DeployLogger logger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { + private static ApplicationBuilder createFromDirectory(String dir, + FileRegistry fileRegistry, + DeployLogger logger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { return createFromDirectory(dir, MockApplicationPackage.fromSearchDefinitionAndRootDirectory(dir), fileRegistry, logger, properties, rankProfileRegistry, queryProfileRegistry); } - private static SchemaBuilder createFromDirectory(String dir, - ApplicationPackage applicationPackage, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { - SchemaBuilder builder = new SchemaBuilder(applicationPackage, - fileRegistry, - deployLogger, - properties, - rankProfileRegistry, - queryProfileRegistry); - for (Iterator<Path> i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) { - builder.importFile(i.next()); + private static ApplicationBuilder createFromDirectory(String dir, + ApplicationPackage applicationPackage, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { + ApplicationBuilder builder = new ApplicationBuilder(applicationPackage, + fileRegistry, + deployLogger, + properties, + rankProfileRegistry, + queryProfileRegistry); + for (var i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) { + builder.addSchemaFile(i.next().toString()); } builder.build(true); return builder; @@ -513,15 +516,15 @@ public class SchemaBuilder { * Convenience factory method to import and build a {@link Schema} object from a raw object. * * @param rawSchema the raw object to build from - * @return the built {@link SchemaBuilder} object - * @see #importRawSchema(Schema) + * @return the built {@link ApplicationBuilder} object + * @see #add(Schema) */ - public static SchemaBuilder createFromRawSchema(Schema rawSchema, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) { - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry, queryProfileRegistry); - builder.importRawSchema(rawSchema); - builder.build(); + public static ApplicationBuilder createFromRawSchema(Schema rawSchema, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) { + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry, queryProfileRegistry); + builder.add(rawSchema); + builder.build(true); return builder; } @@ -530,7 +533,7 @@ public class SchemaBuilder { * * @param rawSchema the raw object to build from * @return the built {@link Schema} object - * @see #importRawSchema(Schema) + * @see #add(Schema) */ public static Schema buildFromRawSchema(Schema rawSchema, RankProfileRegistry rankProfileRegistry, @@ -550,4 +553,10 @@ public class SchemaBuilder { public DeployLogger getDeployLogger() { return deployLogger; } + @SuppressWarnings("EmptyCatchBlock") + private static void closeIgnoreException(Reader reader) { + try { + reader.close(); + } catch(Exception e) {} + } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java index 56a739ced8b..4444636fbe8 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java @@ -40,14 +40,14 @@ public class DefaultRankProfile extends RankProfile { RankSetting setting = super.getRankSetting(fieldOrIndex,type); if (setting != null) return setting; - ImmutableSDField field = getSearch().getConcreteField(fieldOrIndex); + ImmutableSDField field = schema().getConcreteField(fieldOrIndex); if (field != null) { setting = toRankSetting(field,type); if (setting != null) return setting; } - Index index = getSearch().getIndex(fieldOrIndex); + Index index = schema().getIndex(fieldOrIndex); if (index != null) { setting = toRankSetting(index,type); if (setting != null) @@ -89,7 +89,7 @@ public class DefaultRankProfile extends RankProfile { public Set<RankSetting> rankSettings() { Set<RankSetting> settings = new LinkedHashSet<>(20); settings.addAll(this.rankSettings); - for (ImmutableSDField field : getSearch().allConcreteFields() ) { + for (ImmutableSDField field : schema().allConcreteFields() ) { addSetting(field, RankSetting.Type.WEIGHT, settings); addSetting(field, RankSetting.Type.RANKTYPE, settings); addSetting(field, RankSetting.Type.LITERALBOOST, settings); @@ -97,7 +97,7 @@ public class DefaultRankProfile extends RankProfile { } // Foer settings that really pertains to indexes do the explicit indexes too - for (Index index : getSearch().getExplicitIndices()) { + for (Index index : schema().getExplicitIndices()) { addSetting(index, RankSetting.Type.PREFERBITVECTOR, settings); } return settings; diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java index 55f24123940..17d9bf635fa 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java @@ -48,12 +48,12 @@ public class DocumentModelBuilder { private final DocumentModel model; - public DocumentModelBuilder(DocumentModel model) { - this.model = model; - model.getDocumentManager().add(VespaDocumentType.INSTANCE); + public DocumentModelBuilder() { + this.model = new DocumentModel(); + this.model.getDocumentManager().add(VespaDocumentType.INSTANCE); } - public void addToModel(Collection<Schema> schemaList) { + public DocumentModel build(Collection<Schema> schemaList) { List<SDDocumentType> docList = new LinkedList<>(); for (Schema schema : schemaList) { docList.add(schema.getDocument()); @@ -65,6 +65,7 @@ public class DocumentModelBuilder { toAdd = tryAdd(schemaList)) { schemaList = toAdd; } + return model; } private List<SDDocumentType> sortDocumentTypes(List<SDDocumentType> docList) { @@ -124,7 +125,7 @@ public class DocumentModelBuilder { return left; } - public void addToModel(Schema schema) { + private void addToModel(Schema schema) { // Then we add the search specific stuff SearchDef searchDef = new SearchDef(schema.getName()); addSearchFields(schema.extraFieldList(), searchDef); @@ -232,8 +233,7 @@ public class DocumentModelBuilder { @SuppressWarnings("deprecation") private static DataType resolveTemporariesRecurse(DataType type, DataTypeCollection repo, Collection<NewDocumentType> docs, - Set<TypeReplacement> replacements) - { + Set<TypeReplacement> replacements) { DataType original = type; if (type instanceof TemporaryStructuredDataType) { DataType other = repo.getDataType(type.getId()); @@ -298,8 +298,7 @@ public class DocumentModelBuilder { } private static DataType specialHandleAnnotationReferenceRecurse(NewDocumentType docType, String fieldName, - DataType dataType) - { + DataType dataType) { if (dataType instanceof TemporaryAnnotationReferenceDataType) { TemporaryAnnotationReferenceDataType refType = (TemporaryAnnotationReferenceDataType)dataType; if (refType.getId() != 0) { @@ -359,6 +358,7 @@ public class DocumentModelBuilder { addType(dt, s); return s; } + private static boolean anyParentsHavePayLoad(SDAnnotationType sa, SDDocumentType sdoc) { if (sa.getInherits() != null) { AnnotationType tmp = sdoc.findAnnotation(sa.getInherits()); @@ -367,7 +367,7 @@ public class DocumentModelBuilder { } return false; } - @SuppressWarnings("deprecation") + private NewDocumentType convert(SDDocumentType sdoc) { Map<AnnotationType, String> annotationInheritance = new HashMap<>(); Map<StructDataType, String> structInheritance = new HashMap<>(); @@ -463,6 +463,7 @@ public class DocumentModelBuilder { } } } + private static void extractNestedTypes(NewDocumentType dt, DataType type) { if (type instanceof StructDataType) { StructDataType tmp = (StructDataType) type; @@ -484,8 +485,11 @@ public class DocumentModelBuilder { throw new IllegalArgumentException(type.toString()); } } + private static boolean testAddType(NewDocumentType dt, DataType type) { return internalAddType(dt, type, true); } + private static boolean addType(NewDocumentType dt, DataType type) { return internalAddType(dt, type, false); } + private static boolean internalAddType(NewDocumentType dt, DataType type, boolean dryRun) { DataType oldType = dt.getDataTypeRecursive(type.getId()); if (oldType == null) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java index c672b662874..1d71a9f1494 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.application.api.FileRegistry; import com.yahoo.config.model.api.ModelContext; @@ -14,8 +15,11 @@ import com.yahoo.searchdefinition.document.SDDocumentType; */ public class DocumentOnlySchema extends Schema { - public DocumentOnlySchema(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - super(application, fileRegistry, deployLogger, properties); + public DocumentOnlySchema(ApplicationPackage applicationPackage, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties) { + super(applicationPackage, fileRegistry, deployLogger, properties); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index 5f6bde3b791..1b6c4aa9459 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -57,11 +57,12 @@ public class RankProfile implements Cloneable { public final static String FIRST_PHASE = "firstphase"; public final static String SECOND_PHASE = "secondphase"; + /** The search definition-unique name of this rank profile */ private final String name; - /** The search definition owning this profile, or null if global (owned by a model) */ - private final ImmutableSchema search; + /** The schema owning this profile, or null if global (owned by a model) */ + private final ImmutableSchema schema; /** The name of the rank profile inherited by this */ private String inheritedName = null; @@ -132,20 +133,6 @@ public class RankProfile implements Cloneable { private final ApplicationPackage applicationPackage; private final DeployLogger deployLogger; - private static class CachedFunctions { - private final Map<String, RankingExpressionFunction> allRankingExpressionFunctions; - private final ImmutableMap<String, ExpressionFunction> allExpressionFunctions; - CachedFunctions(Map<String, RankingExpressionFunction> functions) { - allRankingExpressionFunctions = functions; - ImmutableMap.Builder<String,ExpressionFunction> mapBuilder = new ImmutableMap.Builder<>(); - for (var entry : functions.entrySet()) { - ExpressionFunction function = entry.getValue().function(); - mapBuilder.put(function.getName(), function); - } - allExpressionFunctions = mapBuilder.build(); - } - } - /** * Creates a new rank profile for a particular search definition * @@ -156,7 +143,7 @@ public class RankProfile implements Cloneable { */ public RankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { this.name = Objects.requireNonNull(name, "name cannot be null"); - this.search = Objects.requireNonNull(schema, "search cannot be null"); + this.schema = Objects.requireNonNull(schema, "search cannot be null"); this.onnxModels = null; this.rankingConstants = rankingConstants; this.rankProfileRegistry = rankProfileRegistry; @@ -172,7 +159,7 @@ public class RankProfile implements Cloneable { public RankProfile(String name, ApplicationPackage applicationPackage, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants, OnnxModels onnxModels) { this.name = Objects.requireNonNull(name, "name cannot be null"); - this.search = null; + this.schema = null; this.rankProfileRegistry = rankProfileRegistry; this.rankingConstants = rankingConstants; this.onnxModels = onnxModels; @@ -180,10 +167,10 @@ public class RankProfile implements Cloneable { this.deployLogger = deployLogger; } - public String getName() { return name; } + public String name() { return name; } /** Returns the search definition owning this, or null if it is global */ - public ImmutableSchema getSearch() { return search; } + public ImmutableSchema schema() { return schema; } /** Returns the application this is part of */ public ApplicationPackage applicationPackage() { @@ -196,19 +183,19 @@ public class RankProfile implements Cloneable { } public Map<String, OnnxModel> onnxModels() { - return search != null ? search.onnxModels().asMap() : onnxModels.asMap(); + return schema != null ? schema.onnxModels().asMap() : onnxModels.asMap(); } private Stream<ImmutableSDField> allFields() { - if (search == null) return Stream.empty(); + if (schema == null) return Stream.empty(); if (allFieldsList == null) { - allFieldsList = search.allFieldsList(); + allFieldsList = schema.allFieldsList(); } return allFieldsList.stream(); } private Stream<ImmutableSDField> allImportedFields() { - return search != null ? search.allImportedFields() : Stream.empty(); + return schema != null ? schema.allImportedFields() : Stream.empty(); } /** @@ -228,9 +215,9 @@ public class RankProfile implements Cloneable { if (inherited == null) { inherited = resolveInherited(); if (inherited == null) { - String msg = "rank-profile '" + getName() + "' inherits '" + inheritedName + - "', but it does not exist anywhere in the inheritance of search '" + - ((getSearch() != null) ? getSearch().getName() : " global rank profiles") + "'."; + String msg = "rank-profile '" + name() + "' inherits '" + inheritedName + + "', but this is not found in " + + ((schema() != null) ? schema() : " global rank profiles"); throw new IllegalArgumentException(msg); } else { List<String> children = new ArrayList<>(); @@ -242,9 +229,9 @@ public class RankProfile implements Cloneable { } private String createFullyQualifiedName() { - return (search != null) - ? (search.getName() + "." + getName()) - : getName(); + return (schema != null) + ? (schema.getName() + "." + name()) + : name(); } private void verifyNoInheritanceCycle(List<String> children, RankProfile parent) { @@ -275,8 +262,8 @@ public class RankProfile implements Cloneable { private RankProfile resolveInherited() { if (inheritedName == null) return null; - return (getSearch() != null) - ? resolveInherited(search) + return (schema() != null) + ? resolveInherited(schema) : rankProfileRegistry.getGlobal(inheritedName); } @@ -289,7 +276,7 @@ public class RankProfile implements Cloneable { public boolean inherits(String name) { RankProfile parent = getInherited(); while (parent != null) { - if (parent.getName().equals(name)) + if (parent.name().equals(name)) return true; parent = parent.getInherited(); } @@ -619,7 +606,7 @@ public class RankProfile implements Cloneable { @Override public String toString() { - return "rank profile '" + getName() + "'"; + return "rank profile '" + name() + "'"; } public int getRerankCount() { @@ -819,14 +806,14 @@ public class RankProfile implements Cloneable { private ExpressionFunction parseRankingExpression(String name, List<String> arguments, String expression) throws ParseException { if (expression.trim().length() == 0) - throw new ParseException("Encountered an empty ranking expression in " + getName()+ ", " + name + "."); + throw new ParseException("Encountered an empty ranking expression in " + name() + ", " + name + "."); try (Reader rankingExpressionReader = openRankingExpressionReader(name, expression.trim())) { return new ExpressionFunction(name, arguments, new RankingExpression(name, rankingExpressionReader)); } catch (com.yahoo.searchlib.rankingexpression.parser.ParseException e) { ParseException exception = new ParseException("Could not parse ranking expression '" + expression.trim() + - "' in " + getName()+ ", " + name + "."); + "' in " + name() + ", " + name + "."); throw (ParseException)exception.initCause(e); } catch (IOException e) { @@ -848,10 +835,10 @@ public class RankProfile implements Cloneable { String fileName = extractFileName(expression); File file = new File(fileName); if (!file.isAbsolute() && file.getPath().contains("/")) // See ticket 4102122 - throw new IllegalArgumentException("In " + getName() + ", " + expName + ", ranking references file '" + file + - "' in subdirectory, which is not supported."); + throw new IllegalArgumentException("In " + name() + ", " + expName + ", ranking references file '" + file + + "' in subdirectory, which is not supported."); - return search.getRankingExpression(fileName); + return schema.getRankingExpression(fileName); } /** Shallow clones this */ @@ -888,7 +875,7 @@ public class RankProfile implements Cloneable { return compiled; } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("Rank profile '" + getName() + "' is invalid", e); + throw new IllegalArgumentException("Rank profile '" + name() + "' is invalid", e); } } @@ -1321,4 +1308,22 @@ public class RankProfile implements Cloneable { } + private static class CachedFunctions { + + private final Map<String, RankingExpressionFunction> allRankingExpressionFunctions; + + private final ImmutableMap<String, ExpressionFunction> allExpressionFunctions; + + CachedFunctions(Map<String, RankingExpressionFunction> functions) { + allRankingExpressionFunctions = functions; + ImmutableMap.Builder<String,ExpressionFunction> mapBuilder = new ImmutableMap.Builder<>(); + for (var entry : functions.entrySet()) { + ExpressionFunction function = entry.getValue().function(); + mapBuilder.put(function.getName(), function); + } + allExpressionFunctions = mapBuilder.build(); + } + + } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java index 08ae3d838ec..75c3aa313c0 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java @@ -6,7 +6,6 @@ import com.yahoo.searchdefinition.document.SDDocumentType; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -44,22 +43,22 @@ public class RankProfileRegistry { /** Adds a rank profile to this registry */ public void add(RankProfile rankProfile) { - String searchName = extractName(rankProfile.getSearch()); - if ( ! rankProfiles.containsKey(searchName)) { - rankProfiles.put(searchName, new LinkedHashMap<>()); + String schemaName = extractName(rankProfile.schema()); + if ( ! rankProfiles.containsKey(schemaName)) { + rankProfiles.put(schemaName, new LinkedHashMap<>()); } checkForDuplicate(rankProfile); - rankProfiles.get(searchName).put(rankProfile.getName(), rankProfile); + rankProfiles.get(schemaName).put(rankProfile.name(), rankProfile); } private void checkForDuplicate(RankProfile rankProfile) { - String rankProfileName = rankProfile.getName(); - RankProfile existingRankProfileWithSameName = rankProfiles.get(extractName(rankProfile.getSearch())).get(rankProfileName); + String rankProfileName = rankProfile.name(); + RankProfile existingRankProfileWithSameName = rankProfiles.get(extractName(rankProfile.schema())).get(rankProfileName); if (existingRankProfileWithSameName == null) return; if ( ! overridableRankProfileNames.contains(rankProfileName)) { throw new IllegalArgumentException("Duplicate rank profile '" + rankProfileName + "' in " + - rankProfile.getSearch()); + rankProfile.schema()); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java index ddad67324ba..4df118545eb 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java @@ -55,6 +55,9 @@ public class Schema implements ImmutableSchema { /** The unique name of this schema */ private String name; + /** The application package this is constructed from */ + private final ApplicationPackage applicationPackage; + /** The name of the schema this should inherit all the content of, if any */ private final Optional<String> inherited; @@ -93,21 +96,22 @@ public class Schema implements ImmutableSchema { /** The resulting processed field */ private Optional<ImportedFields> importedFields = Optional.empty(); - private final Application owner; private final DeployLogger deployLogger; private final ModelContext.Properties properties; + private Application owner; + /** Testing only */ - public Schema(String name) { - this(name, Optional.empty(), null, null, new BaseDeployLogger(), new TestProperties()); + public Schema(String name, ApplicationPackage applicationPackage) { + this(name, applicationPackage, Optional.empty(), null, new BaseDeployLogger(), new TestProperties()); } public Schema(String name, - Application application, + ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - this(name, Optional.empty(), application, fileRegistry, deployLogger, properties); + this(name, applicationPackage, Optional.empty(), fileRegistry, deployLogger, properties); } /** @@ -115,30 +119,30 @@ public class Schema implements ImmutableSchema { * * @param name of the schema * @param inherited the schema this inherits, if any - * @param application the application containing this */ public Schema(String name, + ApplicationPackage applicationPackage, Optional<String> inherited, - Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - this(inherited, application, fileRegistry, deployLogger, properties, false); - this.name = name; + this(inherited, applicationPackage, fileRegistry, deployLogger, properties, false); + this.name = Objects.requireNonNull(name, "A schema must have a name"); } - protected Schema(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - this(Optional.empty(), application, fileRegistry, deployLogger, properties, true); + protected Schema(ApplicationPackage applicationPackage, FileRegistry fileRegistry, + DeployLogger deployLogger, ModelContext.Properties properties) { + this(Optional.empty(), applicationPackage, fileRegistry, deployLogger, properties, true); } private Schema(Optional<String> inherited, - Application application, + ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties, boolean documentsOnly) { this.inherited = inherited; - this.owner = application; + this.applicationPackage = applicationPackage; this.deployLogger = deployLogger; this.properties = properties; this.documentsOnly = documentsOnly; @@ -147,14 +151,21 @@ public class Schema implements ImmutableSchema { onnxModels = new OnnxModels(fileRegistry, Optional.of(this)); } - protected void setName(String name) { - this.name = name; + /** + * Assigns the owner of this + * + * @throws IllegalStateException if an owner is already assigned + */ + public void setOwner(Application owner) { + if (this.owner != null) + throw new IllegalStateException("Cannot reassign the owner of " + this); + this.owner = owner; } + protected void setName(String name) { this.name = name; } + @Override - public String getName() { - return name; - } + public String getName() {return name; } /** Returns true if this only defines a document type, not a full schema */ public boolean isDocumentsOnly() { @@ -311,16 +322,13 @@ public class Schema implements ImmutableSchema { */ @Override public Reader getRankingExpression(String fileName) { - return owner.applicationPackage().getRankingExpression(fileName); + return applicationPackage.getRankingExpression(fileName); } public Application application() { return owner; } @Override - public ApplicationPackage applicationPackage() { - if (owner == null) return null; - return owner.applicationPackage(); - } + public ApplicationPackage applicationPackage() { return applicationPackage; } @Override public DeployLogger getDeployLogger() { return deployLogger; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java index 14e303522e0..bcdc9e656e1 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.config.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.configmodel.producers.DocumentManager; import com.yahoo.vespa.configmodel.producers.DocumentTypes; @@ -11,22 +11,21 @@ import java.util.Collections; import java.util.List; /** - * Auxiliary facade for deriving configs from search definitions + * Facade for deriving configs from schemas * * @author bratseth */ public class Deriver { - public static SchemaBuilder getSearchBuilder(List<String> sds) { - SchemaBuilder builder = new SchemaBuilder(); + public static ApplicationBuilder getSchemaBuilder(List<String> schemas) { + ApplicationBuilder builder = new ApplicationBuilder(); try { - for (String s : sds) { - builder.importFile(s); - } + for (String schema : schemas) + builder.addSchemaFile(schema); } catch (ParseException | IOException e) { throw new IllegalArgumentException(e); } - builder.build(); + builder.build(true); return builder; } @@ -34,22 +33,22 @@ public class Deriver { return getDocumentManagerConfig(Collections.singletonList(sd)); } - public static DocumentmanagerConfig.Builder getDocumentManagerConfig(List<String> sds) { - return new DocumentManager().produce(getSearchBuilder(sds).getModel(), new DocumentmanagerConfig.Builder()); + public static DocumentmanagerConfig.Builder getDocumentManagerConfig(List<String> schemas) { + return new DocumentManager().produce(getSchemaBuilder(schemas).getModel(), new DocumentmanagerConfig.Builder()); } - public static DocumentmanagerConfig.Builder getDocumentManagerConfig(List<String> sds, boolean useV8DocManagerCfg) { + public static DocumentmanagerConfig.Builder getDocumentManagerConfig(List<String> schemas, boolean useV8DocManagerCfg) { return new DocumentManager() .useV8DocManagerCfg(useV8DocManagerCfg) - .produce(getSearchBuilder(sds).getModel(), new DocumentmanagerConfig.Builder()); + .produce(getSchemaBuilder(schemas).getModel(), new DocumentmanagerConfig.Builder()); } - public static DocumenttypesConfig.Builder getDocumentTypesConfig(String sd) { - return getDocumentTypesConfig(Collections.singletonList(sd)); + public static DocumenttypesConfig.Builder getDocumentTypesConfig(String schema) { + return getDocumentTypesConfig(Collections.singletonList(schema)); } - public static DocumenttypesConfig.Builder getDocumentTypesConfig(List<String> sds) { - return new DocumentTypes().produce(getSearchBuilder(sds).getModel(), new DocumenttypesConfig.Builder()); + public static DocumenttypesConfig.Builder getDocumentTypesConfig(List<String> schemas) { + return new DocumentTypes().produce(getSchemaBuilder(schemas).getModel(), new DocumenttypesConfig.Builder()); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java index 3081637c975..86c1d478974 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java @@ -75,7 +75,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ private boolean areDependenciesReady(RankProfile rank, RankProfileRegistry registry) { return (rank.getInheritedName() == null) || rankProfiles.containsKey(rank.getInheritedName()) || - (rank.getSearch() != null && registry.resolve(rank.getSearch().getDocument(), rank.getInheritedName()) != null); + (rank.schema() != null && registry.resolve(rank.schema().getDocument(), rank.getInheritedName()) != null); } private void deriveRankProfiles(RankProfileRegistry rankProfileRegistry, @@ -92,7 +92,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ } Map<String, RankProfile> remaining = new LinkedHashMap<>(); - rankProfileRegistry.rankProfilesOf(schema).forEach(rank -> remaining.put(rank.getName(), rank)); + rankProfileRegistry.rankProfilesOf(schema).forEach(rank -> remaining.put(rank.name(), rank)); remaining.remove("default"); while (!remaining.isEmpty()) { List<RankProfile> ready = new ArrayList<>(); @@ -100,7 +100,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ if (areDependenciesReady(rank, rankProfileRegistry)) ready.add(rank); }); processRankProfiles(ready, queryProfiles, importedModels, schema, attributeFields, deployProperties, executor); - ready.forEach(rank -> remaining.remove(rank.getName())); + ready.forEach(rank -> remaining.remove(rank.name())); } } private void processRankProfiles(List<RankProfile> ready, @@ -116,8 +116,8 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ onnxModels.add(rank.onnxModels()); } - futureRawRankProfiles.put(rank.getName(), executor.submit(() -> new RawRankProfile(rank, largeRankExpressions, queryProfiles, importedModels, - attributeFields, deployProperties))); + futureRawRankProfiles.put(rank.name(), executor.submit(() -> new RawRankProfile(rank, largeRankExpressions, queryProfiles, importedModels, + attributeFields, deployProperties))); } try { for (Future<RawRankProfile> rawFuture : futureRawRankProfiles.values()) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RawRankProfile.java index f775c4e697d..a64f0939677 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RawRankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RawRankProfile.java @@ -62,7 +62,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { public RawRankProfile(RankProfile rankProfile, LargeRankExpressions largeExpressions, QueryProfileRegistry queryProfiles, ImportedMlModels importedModels, AttributeFields attributeFields, ModelContext.Properties deployProperties) { - this.name = rankProfile.getName(); + this.name = rankProfile.name(); compressedProperties = compress(new Deriver(rankProfile.compile(queryProfiles, importedModels), attributeFields, deployProperties).derive(largeExpressions)); } @@ -158,7 +158,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { */ Deriver(RankProfile compiled, AttributeFields attributeFields, ModelContext.Properties deployProperties) { - rankprofileName = compiled.getName(); + rankprofileName = compiled.name(); attributeTypes = compiled.getAttributeTypes(); queryFeatureTypes = compiled.getQueryFeatureTypes(); firstPhaseRanking = compiled.getFirstPhaseRanking(); @@ -447,8 +447,8 @@ public class RawRankProfile implements RankProfilesConfig.Producer { } private void deriveOnnxModelFunctionsAndFeatures(RankProfile rankProfile) { - if (rankProfile.getSearch() == null) return; - if (rankProfile.getSearch().onnxModels().asMap().isEmpty()) return; + if (rankProfile.schema() == null) return; + if (rankProfile.schema().onnxModels().asMap().isEmpty()) return; replaceOnnxFunctionInputs(rankProfile); replaceImplicitOnnxConfigFeatures(summaryFeatures, rankProfile); replaceImplicitOnnxConfigFeatures(matchFeatures, rankProfile); @@ -457,7 +457,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { private void replaceOnnxFunctionInputs(RankProfile rankProfile) { Set<String> functionNames = rankProfile.getFunctions().keySet(); if (functionNames.isEmpty()) return; - for (OnnxModel onnxModel: rankProfile.getSearch().onnxModels().asMap().values()) { + for (OnnxModel onnxModel: rankProfile.schema().onnxModels().asMap().values()) { for (Map.Entry<String, String> mapping : onnxModel.getInputMap().entrySet()) { String source = mapping.getValue(); if (functionNames.contains(source)) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java index 96f2f2f1d24..b4d76445507 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java @@ -29,11 +29,7 @@ public class TemporaryImportedFields { } public boolean hasField(String fieldName) { - boolean has = fields.get(fieldName) != null; - if (has) return true; - if (owner.inherited().isEmpty()) return false; - if (owner.inherited().get().temporaryImportedFields().isEmpty()) return false; - return owner.inherited().get().temporaryImportedFields().get().hasField(fieldName); + return fields.get(fieldName) != null; } public Map<String, TemporaryImportedField> fields() { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java index 6d9f4cdec92..35ee9ddb9ed 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java @@ -49,12 +49,12 @@ public class OnnxModelTransformer extends ExpressionTransformer<RankProfileTrans private ExpressionNode transformFeature(ReferenceNode feature, RankProfileTransformContext context) { if (context.rankProfile() == null) return feature; - if (context.rankProfile().getSearch() == null) return feature; + if (context.rankProfile().schema() == null) return feature; return transformFeature(feature, context.rankProfile()); } public static ExpressionNode transformFeature(ReferenceNode feature, RankProfile rankProfile) { - ImmutableSchema search = rankProfile.getSearch(); + ImmutableSchema search = rankProfile.schema(); final String featureName = feature.getName(); if ( ! featureName.equals("onnxModel") && ! featureName.equals("onnx")) return feature; diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/SimpleCharStream.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/SimpleCharStream.java index cde172d00b9..0b275c6a722 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/SimpleCharStream.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/SimpleCharStream.java @@ -6,11 +6,11 @@ import com.yahoo.javacc.FastCharStream; /** * @author Simon Thoresen Hult */ -@SuppressWarnings("deprecation") public class SimpleCharStream extends FastCharStream implements com.yahoo.searchdefinition.parser.CharStream, - com.yahoo.vespa.indexinglanguage.parser.CharStream -{ + com.yahoo.vespa.indexinglanguage.parser.CharStream { + public SimpleCharStream(String input) { super(input); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java index 5643bb660f1..3759fc453df 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java @@ -30,7 +30,7 @@ public class DiversitySettingsValidator extends Processor { } private void validate(RankProfile rankProfile, RankProfile.DiversitySettings settings) { String attributeName = settings.getAttribute(); - new AttributeValidator(schema.getName(), rankProfile.getName(), + new AttributeValidator(schema.getName(), rankProfile.name(), schema.getAttribute(attributeName), attributeName).validate(); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java index d89f83c333f..3f97bf83565 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java @@ -63,7 +63,7 @@ public class FilterFieldNames extends Processor { filterFields.add(fieldName); } } else { - deployLogger.logApplicationPackage(Level.WARNING, "For rank profile '" + profile.getName() + "': Cannot apply rank filter setting to unexisting field '" + fieldName + "'"); + deployLogger.logApplicationPackage(Level.WARNING, "For rank profile '" + profile.name() + "': Cannot apply rank filter setting to unexisting field '" + fieldName + "'"); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java index b697c584ece..4eae6b47833 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java @@ -35,7 +35,7 @@ public class MatchPhaseSettingsValidator extends Processor { private void validateMatchPhaseSettings(RankProfile rankProfile, RankProfile.MatchPhaseSettings settings) { String attributeName = settings.getAttribute(); new AttributeValidator(schema.getName(), - rankProfile.getName(), + rankProfile.name(), schema.getAttribute(attributeName), attributeName).validate(); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java index f5c3fa35e34..e6adb8b683b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java @@ -89,10 +89,10 @@ public class RankingExpressionTypeResolver extends Processor { if ( context.tensorsAreUsed() && ! context.queryFeaturesNotDeclared().isEmpty() && ! warnedAbout.containsAll(context.queryFeaturesNotDeclared())) { - deployLogger.logApplicationPackage(Level.WARNING, "The following query features used in '" + profile.getName() + - "' are not declared in query profile " + - "types and will be interpreted as scalars, not tensors: " + - context.queryFeaturesNotDeclared()); + deployLogger.logApplicationPackage(Level.WARNING, "The following query features used in '" + profile.name() + + "' are not declared in query profile " + + "types and will be interpreted as scalars, not tensors: " + + context.queryFeaturesNotDeclared()); warnedAbout.addAll(context.queryFeaturesNotDeclared()); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java index 8194b9f9e06..f4f920d9ec8 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java @@ -35,9 +35,9 @@ public class ReservedFunctionNames extends Processor { for (String functionName : rp.getFunctions().keySet()) { if (reservedNames.contains(functionName)) { deployLogger.logApplicationPackage(Level.WARNING, "Function '" + functionName + "' " + - "in rank profile '" + rp.getName() + "' " + - "has a reserved name. This might mean that the function shadows " + - "the built-in function with the same name." + "in rank profile '" + rp.name() + "' " + + "has a reserved name. This might mean that the function shadows " + + "the built-in function with the same name." ); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentModel.java b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentModel.java index 112385e1801..15599c567ab 100644 --- a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentModel.java @@ -16,16 +16,8 @@ public class DocumentModel { private final DocumentTypeRepo documentMan = new DocumentTypeRepo(); private final SearchManager searchMan = new SearchManager(); - /** - * - * @return Returns the DocumentManager - */ public DocumentTypeRepo getDocumentManager() { return documentMan; } - /** - * - * @return Returns the SearchManager - */ public SearchManager getSearchManager() { return searchMan; } } 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()); } diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index 92633f61e67..b4d2af42f55 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -22,7 +22,7 @@ import com.yahoo.document.*; import com.yahoo.documentmodel.*; import com.yahoo.compress.Compressor; import com.yahoo.compress.CompressionType; -import com.yahoo.searchdefinition.Application; +import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.searchdefinition.DistributableResource; import com.yahoo.searchdefinition.document.*; import com.yahoo.searchdefinition.document.annotation.SDAnnotationType; @@ -73,7 +73,7 @@ import java.util.logging.Level; public class SDParser { private DocumentTypeManager docMan = null; - private Application application; + private ApplicationPackage applicationPackage; private FileRegistry fileRegistry; private DeployLogger deployLogger; private ModelContext.Properties properties; @@ -86,17 +86,17 @@ public class SDParser { * @param documentsOnly true to only parse the document aspect of a schema (e.g skip rank profiles) */ public SDParser(SimpleCharStream stream, + ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties, - Application application, RankProfileRegistry rankProfileRegistry, boolean documentsOnly) { this(stream); + this.applicationPackage = applicationPackage; this.fileRegistry = fileRegistry; this.deployLogger = deployLogger; this.properties = properties; - this.application = application; this.rankProfileRegistry = rankProfileRegistry; this.documentsOnly = documentsOnly; } @@ -423,7 +423,7 @@ Schema rootSchema(String dir) : } { ( ( <SCHEMA> | <SEARCH> ) name = identifier() (<INHERITS> inherited = identifier() )? { - schema = new Schema(name, Optional.ofNullable(inherited), application, fileRegistry, deployLogger, properties); + schema = new Schema(name, applicationPackage, Optional.ofNullable(inherited), fileRegistry, deployLogger, properties); rankProfileRegistry.add(new DefaultRankProfile(schema, rankProfileRegistry, schema.rankingConstants())); rankProfileRegistry.add(new UnrankedRankProfile(schema, rankProfileRegistry, schema.rankingConstants()));} lbrace() (rootSchemaItem(schema) (<NL>)*)* <RBRACE> (<NL>)* <EOF>) @@ -464,7 +464,7 @@ Object rootSchemaItem(Schema schema) : { } */ Schema rootDocument(String dir) : { - Schema schema = new DocumentOnlySchema(application, fileRegistry, deployLogger, properties); + Schema schema = new DocumentOnlySchema(applicationPackage, fileRegistry, deployLogger, properties); } { ( (rootDocumentItem(schema) (<NL>)*)*<EOF> ) @@ -2561,7 +2561,7 @@ void constantTensor(RankProfile profile, String name) : { <LBRACE> (<NL>)* (( tensorString = tensorValue() | - tensorType = tensorTypeWithPrefix(constantTensorErrorMessage(profile.getName(), name)) ) (<NL>)* )* <RBRACE> + tensorType = tensorTypeWithPrefix(constantTensorErrorMessage(profile.name(), name)) ) (<NL>)* )* <RBRACE> { if (tensorType != null) { profile.addConstantTensor(name, new TensorValue(Tensor.from(tensorType, tensorString))); diff --git a/config-model/src/test/derived/rankprofilemodularity/rank-profiles.cfg b/config-model/src/test/derived/rankprofilemodularity/rank-profiles.cfg new file mode 100644 index 00000000000..8953a8b6bcf --- /dev/null +++ b/config-model/src/test/derived/rankprofilemodularity/rank-profiles.cfg @@ -0,0 +1,30 @@ +rankprofile[].name "default" +rankprofile[].name "unranked" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "value(0)" +rankprofile[].fef.property[].name "vespa.hitcollector.heapsize" +rankprofile[].fef.property[].value "0" +rankprofile[].fef.property[].name "vespa.hitcollector.arraysize" +rankprofile[].fef.property[].value "0" +rankprofile[].fef.property[].name "vespa.dump.ignoredefaultfeatures" +rankprofile[].fef.property[].value "true" +rankprofile[].name "in_schema1" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "nativeRank" +rankprofile[].name "in_schema2" +rankprofile[].fef.property[].name "rankingExpression(fo2).rankingScript" +rankprofile[].fef.property[].value "random" +rankprofile[].fef.property[].name "rankingExpression(f2).rankingScript" +rankprofile[].fef.property[].value "fieldMatch(title) + rankingExpression(fo2)" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "rankingExpression(f2)" +rankprofile[].name "outside_schema1" +rankprofile[].fef.property[].name "rankingExpression(fo1).rankingScript" +rankprofile[].fef.property[].value "now" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "nativeRank" +rankprofile[].name "outside_schema2" +rankprofile[].fef.property[].name "rankingExpression(fo2).rankingScript" +rankprofile[].fef.property[].value "random" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "fieldMatch(title).completeness" diff --git a/config-model/src/test/derived/rankprofilemodularity/test.sd b/config-model/src/test/derived/rankprofilemodularity/test.sd new file mode 100644 index 00000000000..720e2143f17 --- /dev/null +++ b/config-model/src/test/derived/rankprofilemodularity/test.sd @@ -0,0 +1,31 @@ +schema test { + + document test { + + field title type string { + indexing: index + } + + } + + rank-profile in_schema1 { + + first-phase { + expression: nativeRank + } + + } + + rank-profile in_schema2 inherits outside_schema2 { + + function f2() { + expression: fieldMatch(title) + fo2 + } + + first-phase { + expression: f2 + } + + } + +}
\ No newline at end of file diff --git a/config-model/src/test/derived/rankprofilemodularity/test/outside_schema1.profile b/config-model/src/test/derived/rankprofilemodularity/test/outside_schema1.profile new file mode 100644 index 00000000000..a8092689b7f --- /dev/null +++ b/config-model/src/test/derived/rankprofilemodularity/test/outside_schema1.profile @@ -0,0 +1,7 @@ +rank-profile outside_schema1 inherits in_schema1 { + + function fo1() { + expression: now + } + +}
\ No newline at end of file diff --git a/config-model/src/test/derived/rankprofilemodularity/test/outside_schema2.profile b/config-model/src/test/derived/rankprofilemodularity/test/outside_schema2.profile new file mode 100644 index 00000000000..8cf3fcfbb78 --- /dev/null +++ b/config-model/src/test/derived/rankprofilemodularity/test/outside_schema2.profile @@ -0,0 +1,11 @@ +rank-profile outside_schema2 { + + function fo2() { + expression: random + } + + first-phase { + expression: fieldMatch(title).completeness + } + +}
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java index 0ccbec529ed..3acc44113d0 100644 --- a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java @@ -18,7 +18,6 @@ import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.config.ConfigDefinition; import com.yahoo.vespa.config.ConfigDefinitionKey; import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.search.NamedSchema; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -55,19 +54,18 @@ public class ApplicationDeployTest { public void testVespaModel() throws SAXException, IOException { ApplicationPackageTester tester = ApplicationPackageTester.create(TESTDIR + "app1"); new VespaModel(tester.app()); - List<NamedSchema> schemas = tester.getSchemas(); + List<Schema> schemas = tester.getSchemas(); assertEquals(schemas.size(), 5); - for (NamedSchema searchDefinition : schemas) { - Schema s = searchDefinition.getSearch(); - switch (s.getName()) { + for (Schema schema : schemas) { + switch (schema.getName()) { case "music": case "laptop": case "pc": case "sock": break; case "product": - assertTrue(s instanceof DocumentOnlySchema); - assertEquals(DataType.STRING, s.getDocument().getField("title").getDataType()); + assertTrue(schema instanceof DocumentOnlySchema); + assertEquals(DataType.STRING, schema.getDocument().getField("title").getDataType()); break; default: fail(); @@ -95,8 +93,8 @@ public class ApplicationDeployTest { // Check that getFilename works ArrayList<String> sdFileNames = new ArrayList<>(); - for (NamedSchema sd : schemas) - sdFileNames.add(sd.getFilename()); + for (Schema schema : schemas) + sdFileNames.add(schema.getName() + ApplicationPackage.SD_NAME_SUFFIX); Collections.sort(sdFileNames); assertEquals("laptop.sd", sdFileNames.get(0)); assertEquals("music.sd", sdFileNames.get(1)); diff --git a/config-model/src/test/java/com/yahoo/config/model/ApplicationPackageTester.java b/config-model/src/test/java/com/yahoo/config/model/ApplicationPackageTester.java index 3d799375420..96186150108 100644 --- a/config-model/src/test/java/com/yahoo/config/model/ApplicationPackageTester.java +++ b/config-model/src/test/java/com/yahoo/config/model/ApplicationPackageTester.java @@ -5,7 +5,7 @@ import com.yahoo.component.Version; import com.yahoo.config.model.application.provider.ApplicationPackageXmlFilesValidator; import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.vespa.model.search.NamedSchema; +import com.yahoo.searchdefinition.Schema; import java.io.File; import java.io.IOException; @@ -39,7 +39,7 @@ public class ApplicationPackageTester { public FilesApplicationPackage app() { return applicationPackage; } - public List<NamedSchema> getSchemas() { + public List<Schema> getSchemas() { return new DeployState.Builder().applicationPackage(app()).build().getSchemas(); } diff --git a/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java b/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java index f1bebdb0a29..d4ebbe62507 100644 --- a/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java @@ -5,12 +5,10 @@ import com.yahoo.document.DataType; import com.yahoo.document.DataTypeName; import com.yahoo.documentmodel.VespaDocumentType; import com.yahoo.searchdefinition.AbstractSchemaTestCase; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; -import com.yahoo.searchdefinition.processing.ImportedFieldsResolver; -import com.yahoo.searchdefinition.processing.OnnxModelTypeResolver; import com.yahoo.vespa.model.test.utils.DeployLoggerStub; import org.junit.Test; @@ -122,8 +120,8 @@ public class SDDocumentTypeTestCase extends AbstractSchemaTestCase { " }" + "}"); - SchemaBuilder builder = new SchemaBuilder(new DeployLoggerStub()); - builder.importString(schemaLines); + ApplicationBuilder builder = new ApplicationBuilder(new DeployLoggerStub()); + builder.addSchema(schemaLines); builder.build(true); var application = builder.application(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java index aaf75f0c852..2ed1ab6892a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java @@ -22,7 +22,7 @@ public class ArraysTestCase extends AbstractSchemaTestCase { @Test public void testArrayImporting() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/arrays.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/arrays.sd"); SDField tags = (SDField) schema.getDocument().getField("tags"); assertEquals(DataType.STRING, ((CollectionDataType)tags.getDataType()).getNestedType()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java index 1dd2c987d90..9c70fcf79f7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertTrue; public class ArraysWeightedSetsTestCase extends AbstractSchemaTestCase { @Test public void testArrayWeightedSetsImporting() throws java.io.IOException, com.yahoo.searchdefinition.parser.ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/arraysweightedsets.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/arraysweightedsets.sd"); SDField tags = (SDField) schema.getDocument().getField("tags"); assertTrue(tags.getDataType() instanceof ArrayDataType); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java index e4de0aef622..7b2ed2d7a7f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java @@ -30,7 +30,7 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { @Test public void testAttributeSettings() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/attributesettings.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/attributesettings.sd"); SDField f1=(SDField) schema.getDocument().getField("f1"); assertEquals(1, f1.getAttributes().size()); @@ -91,22 +91,22 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { @Test public void requireThatFastAccessCanBeSet() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/attributesettings.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/attributesettings.sd"); SDField field = (SDField) schema.getDocument().getField("fast_access"); assertEquals(1, field.getAttributes().size()); Attribute attr = field.getAttributes().get(field.getName()); assertTrue(attr.isFastAccess()); } - private Schema getSearch(String sd) throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(sd); - builder.build(); + private Schema getSchema(String sd) throws ParseException { + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(sd); + builder.build(true); return builder.getSchema(); } private Attribute getAttributeF(String sd) throws ParseException { - Schema schema = getSearch(sd); + Schema schema = getSchema(sd); SDField field = (SDField) schema.getDocument().getField("f"); return field.getAttributes().get(field.getName()); } @@ -153,14 +153,14 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { @Test public void requireThatMutableCanNotbeSetInDocument() throws ParseException { try { - getSearch("search test {\n" + - " document test {\n" + - " field f type int {\n" + - " indexing: attribute\n" + - " attribute: mutable\n" + - " }\n" + - " }\n" + - "}\n"); + getSchema("search test {\n" + + " document test {\n" + + " field f type int {\n" + + " indexing: attribute\n" + + " attribute: mutable\n" + + " }\n" + + " }\n" + + "}\n"); fail(); } catch (IllegalArgumentException e) { assertEquals("Field 'f' in 'test' can not be marked mutable as it is inside the document clause.", e.getMessage()); @@ -185,7 +185,7 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { } private Schema getSearchWithMutables() throws ParseException { - return getSearch( + return getSchema( "search test {\n" + " document test { \n" + " field a type int { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java index 8b7f0885907..3e92c1df9e7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java @@ -18,7 +18,7 @@ public class CommentTestCase extends AbstractSchemaTestCase { @Test public void testComments() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/comment.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/comment.sd"); SDField field = schema.getConcreteField("a"); assertEquals("{ input a | tokenize normalize stem:\"BEST\" | summary a | index a; }", field.getIndexingScript().toString()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java index 7c5c5c6fccc..ca7313a5c3f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java @@ -15,8 +15,8 @@ public class DiversityTestCase { @Test public void testDiversity() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type int { \n" + @@ -42,7 +42,7 @@ public class DiversityTestCase { " }\n" + " }\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile.MatchPhaseSettings matchPhase = rankProfileRegistry.get(s, "parent").getMatchPhaseSettings(); RankProfile.DiversitySettings diversity = matchPhase.getDiversity(); @@ -60,10 +60,10 @@ public class DiversityTestCase { } @Test public void requireSingleNumericOrString() throws ParseException { - SchemaBuilder builder = getSearchBuilder("field b type predicate { indexing: attribute }"); + ApplicationBuilder builder = getSearchBuilder("field b type predicate { indexing: attribute }"); try { - builder.build(); + builder.build(true); fail("Should throw."); } catch (IllegalArgumentException e) { assertEquals(getMessagePrefix() + "must be single value numeric, or enumerated attribute, but it is 'predicate'", e.getMessage()); @@ -72,19 +72,19 @@ public class DiversityTestCase { @Test public void requireSingle() throws ParseException { - SchemaBuilder builder = getSearchBuilder("field b type array<int> { indexing: attribute }"); + ApplicationBuilder builder = getSearchBuilder("field b type array<int> { indexing: attribute }"); try { - builder.build(); + builder.build(true); fail("Should throw."); } catch (IllegalArgumentException e) { assertEquals(getMessagePrefix() + "must be single value numeric, or enumerated attribute, but it is 'Array<int>'", e.getMessage()); } } - private SchemaBuilder getSearchBuilder(String diversity) throws ParseException { + private ApplicationBuilder getSearchBuilder(String diversity) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type int { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java index fb552f5cfb0..81a44261daf 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.ReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -143,7 +144,7 @@ public class DocumentGraphValidatorTest { } private static Schema createSearchWithName(String name, Schema... parents) { - Schema campaignSchema = new Schema(name); + Schema campaignSchema = new Schema(name, MockApplicationPackage.createEmpty()); SDDocumentType document = new SDDocumentType(name); campaignSchema.addDocument(document); document.setDocumentReferences(new DocumentReferences(Collections.emptyMap())); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java index cc45a2aaec0..66f1850bd10 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.document.ReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; @@ -32,7 +33,7 @@ public class DocumentReferenceResolverTest { @Test public void reference_from_one_document_to_another_is_resolved() { // Create bar document with no fields - Schema barSchema = new Schema(BAR); + Schema barSchema = new Schema(BAR, MockApplicationPackage.createEmpty()); SDDocumentType barDocument = new SDDocumentType(BAR, barSchema); barSchema.addDocument(barDocument); @@ -41,7 +42,7 @@ public class DocumentReferenceResolverTest { ("bar_ref", ReferenceDataType.createWithInferredId(barDocument.getDocumentType())); AttributeUtils.addAttributeAspect(fooRefToBarField); SDField irrelevantField = new SDField("irrelevant_stuff", DataType.INT); - Schema fooSchema = new Schema(FOO); + Schema fooSchema = new Schema(FOO, MockApplicationPackage.createEmpty()); SDDocumentType fooDocument = new SDDocumentType("foo", fooSchema); fooDocument.addField(fooRefToBarField); fooDocument.addField(irrelevantField); @@ -64,7 +65,7 @@ public class DocumentReferenceResolverTest { SDField fooRefToBarField = new SDField( "bar_ref", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("bar"))); AttributeUtils.addAttributeAspect(fooRefToBarField); - Schema fooSchema = new Schema(FOO); + Schema fooSchema = new Schema(FOO, MockApplicationPackage.createEmpty()); SDDocumentType fooDocument = new SDDocumentType("foo", fooSchema); fooDocument.addField(fooRefToBarField); fooSchema.addDocument(fooDocument); @@ -80,14 +81,14 @@ public class DocumentReferenceResolverTest { @Test public void throws_exception_if_reference_is_not_an_attribute() { // Create bar document with no fields - Schema barSchema = new Schema(BAR); + Schema barSchema = new Schema(BAR, MockApplicationPackage.createEmpty()); SDDocumentType barDocument = new SDDocumentType("bar", barSchema); barSchema.addDocument(barDocument); // Create foo document with document reference to bar SDField fooRefToBarField = new SDField ("bar_ref", ReferenceDataType.createWithInferredId(barDocument.getDocumentType())); - Schema fooSchema = new Schema(FOO); + Schema fooSchema = new Schema(FOO, MockApplicationPackage.createEmpty()); SDDocumentType fooDocument = new SDDocumentType("foo", fooSchema); fooDocument.addField(fooRefToBarField); fooSchema.addDocument(fooDocument); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java index 4057fc469bc..7d2386030da 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.document.ReferenceDataType; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -19,7 +20,7 @@ public class ImportedFieldsEnumeratorTest { @Test public void imported_fields_are_enumerated_and_copied_from_correct_search_instance() { String PARENT = "parent"; - Schema parentSchema = new Schema(PARENT); + Schema parentSchema = new Schema(PARENT, MockApplicationPackage.createEmpty()); SDDocumentType parentDocument = new SDDocumentType(PARENT, parentSchema); var parentField = new SDField("their_field", DataType.INT); AttributeUtils.addAttributeAspect(parentField); @@ -27,7 +28,7 @@ public class ImportedFieldsEnumeratorTest { parentSchema.addDocument(parentDocument); String FOO = "foo"; - Schema fooSchema = new Schema(FOO); + Schema fooSchema = new Schema(FOO, MockApplicationPackage.createEmpty()); SDField fooRefToParent = new SDField( "foo_ref", ReferenceDataType.createWithInferredId(parentDocument.getDocumentType())); AttributeUtils.addAttributeAspect(fooRefToParent); @@ -38,7 +39,7 @@ public class ImportedFieldsEnumeratorTest { fooSchema.addDocument(fooDocument); String BAR = "bar"; - Schema barSchema = new Schema(BAR); + Schema barSchema = new Schema(BAR, MockApplicationPackage.createEmpty()); SDField barRefToParent = new SDField( "bar_ref", ReferenceDataType.createWithInferredId(parentDocument.getDocumentType())); AttributeUtils.addAttributeAspect(barRefToParent); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java index 621e7061203..23be59e38f5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java @@ -21,9 +21,9 @@ public class IncorrectRankingExpressionFileRefTestCase extends AbstractSchemaTes public void testIncorrectRef() throws IOException, ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/incorrectrankingexpressionfileref.sd", - registry, - new QueryProfileRegistry()); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/incorrectrankingexpressionfileref.sd", + registry, + new QueryProfileRegistry()); new DerivedConfiguration(schema, registry); // cause rank profile parsing fail("parsing should have failed"); } catch (IllegalArgumentException e) { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java index 55593ef64e4..d81d07bf6e2 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java @@ -15,7 +15,7 @@ public class IncorrectSummaryTypesTestCase extends AbstractSchemaTestCase { @Test public void testImportingIncorrect() throws ParseException { try { - SchemaBuilder.createFromString( + ApplicationBuilder.createFromString( "search incorrectsummarytypes {\n" + " document incorrectsummarytypes {\n" + " field somestring type string {\n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java index f2e50439306..198f8b6c79e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java @@ -21,7 +21,7 @@ public class IndexSettingsTestCase extends AbstractSchemaTestCase { @Test public void testStemmingSettings() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/indexsettings.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/indexsettings.sd"); SDField usingDefault=(SDField) schema.getDocument().getField("usingdefault"); assertEquals(Stemming.SHORTEST,usingDefault.getStemming(schema)); @@ -38,7 +38,7 @@ public class IndexSettingsTestCase extends AbstractSchemaTestCase { @Test public void requireThatInterlavedFeaturesAreSetOnExtraField() throws ParseException { - SchemaBuilder builder = SchemaBuilder.createFromString(joinLines( + ApplicationBuilder builder = ApplicationBuilder.createFromString(joinLines( "search test {", " document test {", " field content type string {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java index 60728ab7d99..8ba7dfdb14f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java @@ -15,13 +15,13 @@ public class IndexingParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatIndexingExpressionsCanBeParsed() throws Exception { - assertNotNull(SchemaBuilder.buildFromFile("src/test/examples/indexing.sd")); + assertNotNull(ApplicationBuilder.buildFromFile("src/test/examples/indexing.sd")); } @Test public void requireThatParseExceptionPositionIsCorrect() throws Exception { try { - SchemaBuilder.buildFromFile("src/test/examples/indexing_invalid_expression.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/indexing_invalid_expression.sd"); } catch (ParseException e) { if (!e.getMessage().contains("at line 5, column 57.")) { throw e; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java index 41321b5c81e..0fcc6e09b02 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java @@ -14,6 +14,6 @@ import java.io.IOException; public class MultipleSummariesTestCase extends AbstractSchemaTestCase { @Test public void testArrayImporting() throws IOException, ParseException { - SchemaBuilder.buildFromFile("src/test/examples/multiplesummaries.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/multiplesummaries.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java index fc94bbe8731..1e766b7793d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java @@ -19,7 +19,7 @@ public class NameFieldCheckTestCase extends AbstractSchemaTestCase { @Test public void testNameField() { try { - SchemaBuilder.createFromString( + ApplicationBuilder.createFromString( "search simple {\n" + " document name-check {\n" + " field title type string {\n" + @@ -40,7 +40,7 @@ public class NameFieldCheckTestCase extends AbstractSchemaTestCase { @Test public void testDuplicateNamesInSearchDifferentType() { try { - SchemaBuilder.createFromString( + ApplicationBuilder.createFromString( "search duplicatenamesinsearch {\n" + " document {\n" + " field grpphotoids64 type string { }\n" + @@ -60,7 +60,7 @@ public class NameFieldCheckTestCase extends AbstractSchemaTestCase { @Test public void testDuplicateNamesInDoc() { try { - SchemaBuilder.createFromString( + ApplicationBuilder.createFromString( "search duplicatenamesindoc {\n" + " document {\n" + " field foo type int {\n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java index 5663473481b..6563fb8d3f1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java @@ -17,7 +17,7 @@ public class OutsideTestCase extends AbstractSchemaTestCase { @Test public void testOutsideIndex() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/outsidedoc.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/outsidedoc.sd"); Index defaultIndex= schema.getIndex("default"); assertTrue(defaultIndex.isPrefix()); @@ -26,7 +26,7 @@ public class OutsideTestCase extends AbstractSchemaTestCase { @Test public void testOutsideSummary() throws IOException, ParseException { - SchemaBuilder.buildFromFile("src/test/examples/outsidesummary.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/outsidesummary.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java index 456a236f293..2b49f3d67a6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java @@ -68,7 +68,7 @@ public class PredicateDataTypeTestCase { lowerBoundParameter(lowerBound) + upperBoundParameter(upperBound)))); - SchemaBuilder sb = SchemaBuilder.createFromString(sd); + ApplicationBuilder sb = ApplicationBuilder.createFromString(sd); for (ImmutableSDField field : sb.getSchema().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { @@ -95,7 +95,7 @@ public class PredicateDataTypeTestCase { "lower-bound: -100000000000000000L\n" + // +'L' upperBoundParameter(upperBound)))); - SchemaBuilder sb = SchemaBuilder.createFromString(sd); + ApplicationBuilder sb = ApplicationBuilder.createFromString(sd); for (ImmutableSDField field : sb.getSchema().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { @@ -113,7 +113,7 @@ public class PredicateDataTypeTestCase { predicateFieldSd( attributeFieldSd( arityParameter(2)))); - SchemaBuilder sb = SchemaBuilder.createFromString(sd); + ApplicationBuilder sb = ApplicationBuilder.createFromString(sd); for (ImmutableSDField field : sb.getSchema().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { @@ -131,7 +131,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Missing arity value in predicate field."); - SchemaBuilder.createFromString(sd); + ApplicationBuilder.createFromString(sd); fail(); } @@ -141,7 +141,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("For schema 'p', field 'pf': Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded."); - SchemaBuilder.createFromString(sd); + ApplicationBuilder.createFromString(sd); } @Test @@ -150,7 +150,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("For schema 'p', field 'pf': Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded."); - SchemaBuilder.createFromString(sd); + ApplicationBuilder.createFromString(sd); } @@ -160,7 +160,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Invalid arity value in predicate field, must be greater than 1."); - SchemaBuilder.createFromString(sd); + ApplicationBuilder.createFromString(sd); } @Test @@ -169,7 +169,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Arity parameter is used only for predicate type fields."); - SchemaBuilder.createFromString(sd); + ApplicationBuilder.createFromString(sd); } @Test @@ -181,7 +181,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Parameters lower-bound and upper-bound are used only for predicate type fields."); - SchemaBuilder.createFromString(sd); + ApplicationBuilder.createFromString(sd); } @Test @@ -193,7 +193,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Collections of predicates are not allowed."); - SchemaBuilder.createFromString(sd); + ApplicationBuilder.createFromString(sd); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java index d2486395340..d07f4513c3c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java @@ -2,6 +2,7 @@ package com.yahoo.searchdefinition; import com.yahoo.config.model.application.provider.FilesApplicationPackage; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.config.model.test.TestDriver; import com.yahoo.config.model.test.TestRoot; import com.yahoo.searchlib.rankingexpression.ExpressionFunction; @@ -33,7 +34,7 @@ public class RankProfileRegistryTest { @Test(expected = IllegalArgumentException.class) public void testRankProfileDuplicateNameIsIllegal() { - Schema schema = new Schema("foo"); + Schema schema = new Schema("foo", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); RankProfile barRankProfile = new RankProfile("bar", schema, rankProfileRegistry, schema.rankingConstants()); rankProfileRegistry.add(barRankProfile); @@ -42,7 +43,7 @@ public class RankProfileRegistryTest { @Test public void testRankProfileDuplicateNameLegalForOverridableRankProfiles() { - Schema schema = new Schema("foo"); + Schema schema = new Schema("foo", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); for (String rankProfileName : RankProfileRegistry.overridableRankProfileNames) { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java index 3fa129eae39..c88e8149e46 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java @@ -6,6 +6,7 @@ import com.yahoo.component.ComponentId; import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.deploy.TestProperties; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.search.query.profile.types.FieldDescription; @@ -43,7 +44,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void testRankProfileInheritance() { - Schema schema = new Schema("test"); + Schema schema = new Schema("test", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); SDDocumentType document = new SDDocumentType("test"); SDField a = document.addField("a", DataType.STRING); @@ -69,8 +70,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatIllegalInheritanceIsChecked() throws ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "search test {", " document test { } ", " rank-profile p1 inherits notexist {}", @@ -78,7 +79,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { builder.build(true); fail(); } catch (IllegalArgumentException e) { - assertEquals("rank-profile 'p1' inherits 'notexist', but it does not exist anywhere in the inheritance of search 'test'.", e.getMessage()); + assertEquals("rank-profile 'p1' inherits 'notexist', but this is not found in schema 'test'", e.getMessage()); } } @@ -86,8 +87,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatSelfInheritanceIsIllegal() throws ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "schema test {", " document test { } ", " rank-profile self inherits self {}", @@ -102,13 +103,13 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatSelfInheritanceIsLegalWhenOverloading() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "schema base {", " document base { } ", " rank-profile self inherits default {}", "}")); - builder.importString(joinLines( + builder.addSchema(joinLines( "schema test {", " document test inherits base { } ", " rank-profile self inherits self {}", @@ -119,8 +120,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatSidewaysInheritanceIsImpossible() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "schema child1 {", " document child1 {", " field field1 type int {", @@ -141,7 +142,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { " }", " }", "}\n")); - builder.importString(joinLines( + builder.addSchema(joinLines( "schema child2 {", " document child2 {", " field field1 type int {", @@ -165,15 +166,15 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { builder.build(true); fail("Sideways inheritance should have been enforced"); } catch (IllegalArgumentException e) { - assertEquals("rank-profile 'child' inherits 'parent', but it does not exist anywhere in the inheritance of search 'child1'.", e.getMessage()); + assertEquals("rank-profile 'child' inherits 'parent', but this is not found in schema 'child1'", e.getMessage()); } } @Test public void requireThatDefaultCanAlwaysBeInherited() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "schema test {", " document test { } ", " rank-profile default inherits default {}", @@ -185,8 +186,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatCyclicInheritanceIsIllegal() throws ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "search test {", " document test { } ", " rank-profile a inherits b {}", @@ -204,8 +205,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatRankProfilesCanInheritNotYetSeenProfiles() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "search test {", " document test { } ", " rank-profile p1 inherits not_yet_defined {}", @@ -246,9 +247,9 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { private void verifyTermwiseLimitAndSomeMoreIncludingInheritance(ModelContext.Properties deployProperties, String sd, Double termwiseLimit) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString(sd); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema(sd); + builder.build(true); Schema schema = builder.getSchema(); AttributeFields attributeFields = new AttributeFields(schema); verifyRankProfile(rankProfileRegistry.get(schema, "parent"), attributeFields, deployProperties, termwiseLimit); @@ -279,8 +280,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatConfigIsDerivedForAttributeTypeSettings() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[10]) { indexing: attribute }", @@ -290,7 +291,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { " rank-profile p1 {}", " rank-profile p2 {}", "}")); - builder.build(); + builder.build(true); Schema schema = builder.getSchema(); assertEquals(4, registry.all().size()); @@ -303,14 +304,14 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatDenseDimensionsMustBeBound() throws ParseException { try { - SchemaBuilder builder = new SchemaBuilder(new RankProfileRegistry()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(new RankProfileRegistry()); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[]) { indexing: attribute }", " }", "}")); - builder.build(); + builder.build(true); } catch (IllegalArgumentException e) { assertEquals("Illegal type in field a type tensor(x[]): Dense tensor dimensions must have a size", @@ -332,8 +333,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatConfigIsDerivedForQueryFeatureTypeSettings() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(registry, setupQueryProfileTypes()); + builder.addSchema(joinLines( "search test {", " document test { } ", " rank-profile p1 {}", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java index d6065e74af5..6de890549c1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java @@ -23,8 +23,8 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { @Test public void testRankPropertyInheritance() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema(joinLines( "search test {", " document test {", " field a type string { ", @@ -48,7 +48,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { " }", " }", "}")); - builder.build(); + builder.build(true); Schema schema = builder.getSchema(); AttributeFields attributeFields = new AttributeFields(schema); @@ -80,8 +80,8 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { @Test public void testRankProfileMutate() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema(joinLines( "search test {", " document test {", " field a type int { ", @@ -128,7 +128,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { " }", " }", "}")); - builder.build(); + builder.build(true); Schema schema = builder.getSchema(); RankProfile a = rankProfileRegistry.get(schema, "a"); List<RankProfile.MutateOperation> operations = a.getMutateOperations(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java index 1925b7e77b9..6eb74dede62 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java @@ -28,8 +28,8 @@ public class RankingConstantTest { final String TENSOR_FILE = "path/my-tensor-file.json"; final String TENSOR_TYPE = "tensor(x{})"; RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); - schemaBuilder.importString(joinLines( + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " rank-profile my_rank_profile {", @@ -43,7 +43,7 @@ public class RankingConstantTest { " }", "}" )); - schemaBuilder.build(); + schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); Iterator<RankingConstant> constantIterator = schema.rankingConstants().asMap().values().iterator(); @@ -59,10 +59,10 @@ public class RankingConstantTest { @Test public void tensor_constant_must_have_a_type() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("must have a type"); - schemaBuilder.importString(joinLines( + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", @@ -75,10 +75,10 @@ public class RankingConstantTest { @Test public void tensor_constant_must_have_a_file() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("must have a file"); - schemaBuilder.importString(joinLines( + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", @@ -91,8 +91,8 @@ public class RankingConstantTest { @Test public void constant_file_does_not_need_path_or_ending() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); - schemaBuilder.importString(joinLines( + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", @@ -101,7 +101,7 @@ public class RankingConstantTest { " }", "}" )); - schemaBuilder.build(); + schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals("simplename", constant.getFileName()); @@ -110,8 +110,8 @@ public class RankingConstantTest { @Test public void constant_uri_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); - schemaBuilder.importString(joinLines( + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", @@ -120,7 +120,7 @@ public class RankingConstantTest { " }", "}" )); - schemaBuilder.build(); + schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); @@ -130,8 +130,8 @@ public class RankingConstantTest { @Test public void constant_https_uri_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); - schemaBuilder.importString(joinLines( + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", @@ -140,7 +140,7 @@ public class RankingConstantTest { " }", "}" )); - schemaBuilder.build(); + schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); @@ -150,8 +150,8 @@ public class RankingConstantTest { @Test public void constant_uri_with_port_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); - schemaBuilder.importString(joinLines( + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", @@ -160,7 +160,7 @@ public class RankingConstantTest { " }", "}" )); - schemaBuilder.build(); + schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); @@ -170,8 +170,8 @@ public class RankingConstantTest { @Test public void constant_uri_no_dual_slashes_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); - schemaBuilder.importString(joinLines( + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", @@ -180,7 +180,7 @@ public class RankingConstantTest { " }", "}" )); - schemaBuilder.build(); + schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); @@ -190,12 +190,12 @@ public class RankingConstantTest { @Test public void constant_uri_only_supports_http_and_https() { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry); String expectedMessage = "Encountered \" <IDENTIFIER> \"ftp\"\" at line 5, column 10.\n\n" + "Was expecting:\n\n" + "<URI_PATH> ..."; try { - schemaBuilder.importString(joinLines( + schemaBuilder.addSchema(joinLines( "search test {", " document test { }", " constant foo {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java index 87b406c39fa..4646ff2f394 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java @@ -25,8 +25,8 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { public void testConstants() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfileRegistry queryProfileRegistry = new QueryProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -66,7 +66,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile parent = rankProfileRegistry.get(s, "parent").compile(queryProfileRegistry, new ImportedMlModels()); assertEquals("0.0", parent.getFirstPhaseRanking().getRoot().toString()); @@ -91,8 +91,8 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testNameCollision() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -110,7 +110,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); try { rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels()); @@ -125,8 +125,8 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testNegativeLiteralArgument() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -141,7 +141,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile profile = rankProfileRegistry.get(s, "test"); assertEquals("safeLog(popShareSlowDecaySignal,-9.21034037)", profile.getFunctions().get("POP_SLOW_SCORE").function().getBody().getRoot().toString()); @@ -150,8 +150,8 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testNegativeConstantArgument() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -169,7 +169,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile profile = rankProfileRegistry.get(s, "test"); assertEquals("safeLog(popShareSlowDecaySignal,myValue)", profile.getFunctions().get("POP_SLOW_SCORE").function().getBody().getRoot().toString()); @@ -180,8 +180,8 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testConstantDivisorInFunction() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " }\n" + @@ -193,7 +193,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile profile = rankProfileRegistry.get(s, "test"); assertEquals("k1 + (k2 + k3) / 1.0E8", @@ -203,8 +203,8 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void test3() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field rating_yelp type int {" + @@ -219,7 +219,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile profile = rankProfileRegistry.get(s, "test"); assertEquals("0.5 + 50 * (attribute(rating_yelp) - 3)", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java index 0598fee538a..94d25deb16a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java @@ -28,8 +28,8 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testFunctionInliningPreserveArithmeticOrdering() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type double { \n" + @@ -65,7 +65,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile parent = rankProfileRegistry.get(s, "parent").compile(new QueryProfileRegistry(), new ImportedMlModels()); @@ -79,8 +79,8 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testConstants() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -125,7 +125,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile parent = rankProfileRegistry.get(s, "parent").compile(new QueryProfileRegistry(), new ImportedMlModels()); @@ -150,8 +150,8 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testNonTopLevelInlining() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type double { \n" + @@ -181,7 +181,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels()); @@ -194,13 +194,13 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { public void testFunctionInliningWithReplacement() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); MockDeployLogger deployLogger = new MockDeployLogger(); - SchemaBuilder builder = new SchemaBuilder(MockApplicationPackage.createEmpty(), - new MockFileRegistry(), - deployLogger, - new TestProperties(), - rankProfileRegistry, - new QueryProfileRegistry()); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(MockApplicationPackage.createEmpty(), + new MockFileRegistry(), + deployLogger, + new TestProperties(), + rankProfileRegistry, + new QueryProfileRegistry()); + builder.addSchema( "search test {\n" + " document test { }\n" + " rank-profile test {\n" + @@ -215,7 +215,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { " }\n" + " }\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels()); assertEquals("foo(2)", test.getFirstPhaseRanking().getRoot().toString()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java index 689b75690ae..ff8a9df4076 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java @@ -16,8 +16,8 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testSelfLoop() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -36,7 +36,7 @@ public class RankingExpressionLoopDetectionTestCase { "\n" + "}\n"); try { - builder.build(); + builder.build(true); fail("Excepted exception"); } catch (IllegalArgumentException e) { @@ -48,8 +48,8 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNestedLoop() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -71,7 +71,7 @@ public class RankingExpressionLoopDetectionTestCase { "\n" + "}\n"); try { - builder.build(); + builder.build(true); fail("Excepted exception"); } catch (IllegalArgumentException e) { @@ -83,8 +83,8 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testSelfArgumentLoop() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -106,7 +106,7 @@ public class RankingExpressionLoopDetectionTestCase { "\n" + "}\n"); try { - builder.build(); + builder.build(true); fail("Excepted exception"); } catch (IllegalArgumentException e) { @@ -118,8 +118,8 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNoLoopWithSameLocalArgument() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -140,14 +140,14 @@ public class RankingExpressionLoopDetectionTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); } @Test public void testNoLoopWithMultipleInvocations() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -168,14 +168,14 @@ public class RankingExpressionLoopDetectionTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); } @Test public void testNoLoopWithBoundIdentifiers() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " }\n" + @@ -191,14 +191,14 @@ public class RankingExpressionLoopDetectionTestCase { " }\n" + " }\n" + "}\n"); - builder.build(); + builder.build(true); } @Test public void testNoLoopWithTheSameNestedIdentifierWhichIsUnbound() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " }\n" + @@ -214,14 +214,14 @@ public class RankingExpressionLoopDetectionTestCase { " }\n" + " }\n" + "}\n"); - builder.build(); + builder.build(true); } @Test public void testNoLoopWithTheSameAlternatingNestedIdentifierWhichIsUnbound() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " }\n" + @@ -240,7 +240,7 @@ public class RankingExpressionLoopDetectionTestCase { " }\n" + " }\n" + "}\n"); - builder.build(); + builder.build(true); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java index ff146fedd88..8354eb59416 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java @@ -26,8 +26,8 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { @Test public void testBasicFunctionShadowing() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -45,7 +45,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels()); List<Pair<String, String>> testRankProperties = createRawRankProfile(test, new QueryProfileRegistry(), s).configProperties(); @@ -61,8 +61,8 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { @Test public void testMultiLevelFunctionShadowing() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -86,7 +86,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels()); List<Pair<String, String>> testRankProperties = createRawRankProfile(test, new QueryProfileRegistry(), s).configProperties(); @@ -113,8 +113,8 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { @Test public void testFunctionShadowingArguments() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -132,7 +132,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { " }\n" + "\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels()); List<Pair<String, String>> testRankProperties = createRawRankProfile(test, new QueryProfileRegistry(), s).configProperties(); @@ -153,8 +153,8 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { // Note: the type assigned to query profile and constant tensors here is not the correct type RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfileRegistry queryProfiles = queryProfileWith("query(q)", "tensor(input[1])"); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry, queryProfiles); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry, queryProfiles); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + @@ -193,7 +193,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { " file: ignored.json\n" + " }\n" + "}\n"); - builder.build(); + builder.build(true); Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(queryProfiles, new ImportedMlModels()); List<Pair<String, String>> testRankProperties = createRawRankProfile(test, queryProfiles, s).configProperties(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java index 299724ea39e..ee3b4ab25e0 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java @@ -32,20 +32,20 @@ public class RankingExpressionValidationTestCase extends AbstractSchemaTestCase } private Schema importWithExpression(String expression, RankProfileRegistry registry) throws ParseException { - SchemaBuilder builder = new SchemaBuilder(registry); - builder.importString("search test {" + - " document test { " + - " field a type string { " + - " indexing: index " + - " }" + - " }" + - " rank-profile default {" + - " first-phase {" + - " expression: " + expression + - " }" + - " }" + - "}"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(registry); + builder.addSchema("search test {" + + " document test { " + + " field a type string { " + + " indexing: index " + + " }" + + " }" + + " rank-profile default {" + + " first-phase {" + + " expression: " + expression + + " }" + + " }" + + "}"); + builder.build(true); return builder.getSchema(); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java index a6f76897c0b..a8aaee83938 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java @@ -15,7 +15,7 @@ public class ReservedWordsAsFieldNamesTestCase extends AbstractSchemaTestCase { @Test public void testIt() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/reserved_words_as_field_names.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/reserved_words_as_field_names.sd"); assertNotNull(schema.getDocument().getField("inline")); assertNotNull(schema.getDocument().getField("constants")); assertNotNull(schema.getDocument().getField("reference")); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java index c2816336076..8a9300a83eb 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java @@ -36,9 +36,9 @@ public class SchemaImporterTestCase extends AbstractSchemaTestCase { @SuppressWarnings("deprecation") public void testSimpleImporting() throws IOException, ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder sb = new SchemaBuilder(rankProfileRegistry, new QueryProfileRegistry()); - sb.importFile("src/test/examples/simple.sd"); - sb.build(); + ApplicationBuilder sb = new ApplicationBuilder(rankProfileRegistry, new QueryProfileRegistry()); + sb.addSchemaFile("src/test/examples/simple.sd"); + sb.build(true); Schema schema = sb.getSchema(); assertEquals("simple", schema.getName()); assertTrue(schema.hasDocument()); @@ -170,7 +170,7 @@ public class SchemaImporterTestCase extends AbstractSchemaTestCase { public void testDocumentImporting() throws IOException, ParseException { try { // Having two documents in one sd-file is illegal. - SchemaBuilder.buildFromFile("src/test/examples/documents.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/documents.sd"); fail(); } catch (IllegalArgumentException e) { } @@ -178,7 +178,7 @@ public class SchemaImporterTestCase extends AbstractSchemaTestCase { @Test public void testIdImporting() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/strange.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/strange.sd"); SDField idecidemyide=(SDField) schema.getDocument().getField("idecidemyide"); assertEquals(5,idecidemyide.getId()); SDField sodoi=(SDField) schema.getDocument().getField("sodoi"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java index dfe60c5871e..c6757938c51 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java @@ -19,13 +19,13 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatIndexingExpressionsCanBeParsed() throws Exception { - assertNotNull(SchemaBuilder.buildFromFile("src/test/examples/simple.sd")); + assertNotNull(ApplicationBuilder.buildFromFile("src/test/examples/simple.sd")); } @Test public void requireThatParseExceptionPositionIsCorrect() throws Exception { try { - SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_construct.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalid_sd_construct.sd"); } catch (ParseException e) { if ( ! e.getMessage().contains("at line 5, column 36.")) { throw e; @@ -36,7 +36,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatParserHandlesLexicalError() throws Exception { try { - SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_lexical_error.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalid_sd_lexical_error.sd"); } catch (ParseException e) { if (!e.getMessage().contains("at line 7, column 27.")) { throw e; @@ -47,7 +47,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireErrorWhenJunkAfterSearchBlock() throws IOException, ParseException { try { - SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_junk_at_end.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalid_sd_junk_at_end.sd"); fail("Illegal junk at end of SD passed"); } catch (ParseException e) { if (!e.getMessage().contains("at line 10, column 1")) { @@ -59,7 +59,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireErrorWhenMissingClosingSearchBracket() throws IOException, ParseException { try { - SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_no_closing_bracket.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalid_sd_no_closing_bracket.sd"); fail("SD without closing bracket passed"); } catch (ParseException e) { if (!e.getMessage().contains("Encountered \"<EOF>\" at line 8, column 1")) { @@ -71,7 +71,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void illegalSearchDefinitionName() throws IOException, ParseException { try { - SchemaBuilder.buildFromFile("src/test/examples/invalid-name.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalid-name.sd"); fail("Name with dash passed"); } catch (ParseException e) { if ( ! e.getMessage().contains("invalid-name")) { @@ -83,7 +83,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { // TODO: Remove in Vespa 8 @Test public void requireThatParserHandlesHeadAndBody() throws IOException, ParseException { - assertNotNull(SchemaBuilder.buildFromFile("src/test/examples/header_body.sd")); + assertNotNull(ApplicationBuilder.buildFromFile("src/test/examples/header_body.sd")); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java index d906685d502..d012f330328 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java @@ -31,7 +31,7 @@ public class SchemaTestCase { " }" + "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SchemaBuilder.createFromStrings(logger, schema); + ApplicationBuilder.createFromStrings(logger, schema); assertEquals("schema 'test' inherits 'nonesuch', but this schema does not exist", logger.entries.get(0).message); fail("Expected failure"); @@ -60,7 +60,7 @@ public class SchemaTestCase { " }" + " }" + "}"); - SchemaBuilder.createFromStrings(new DeployLoggerStub(), parent, child); + ApplicationBuilder.createFromStrings(new DeployLoggerStub(), parent, child); } catch (IllegalArgumentException e) { assertEquals("schema 'child' inherits 'parent', " + @@ -166,12 +166,12 @@ public class SchemaTestCase { " import field parentschema_ref.name as child2_imported {}" + "}"); - SchemaBuilder builder = new SchemaBuilder(new DeployLoggerStub()); + ApplicationBuilder builder = new ApplicationBuilder(new DeployLoggerStub()); builder.processorsToSkip().add(OnnxModelTypeResolver.class); // Avoid discovering the Onnx model referenced does not exist builder.processorsToSkip().add(ImportedFieldsResolver.class); // Avoid discovering the document reference leads nowhere - builder.importString(parentLines); - builder.importString(child1Lines); - builder.importString(child2Lines); + builder.addSchema(parentLines); + builder.addSchema(child1Lines); + builder.addSchema(child2Lines); builder.build(true); var application = builder.application(); @@ -307,12 +307,12 @@ public class SchemaTestCase { " }" + "}"); - SchemaBuilder builder = new SchemaBuilder(new DeployLoggerStub()); + ApplicationBuilder builder = new ApplicationBuilder(new DeployLoggerStub()); builder.processorsToSkip().add(OnnxModelTypeResolver.class); // Avoid discovering the Onnx model referenced does not exist builder.processorsToSkip().add(ImportedFieldsResolver.class); // Avoid discovering the document reference leads nowhere - builder.importString(parentLines); - builder.importString(childLines); - builder.importString(grandchildLines); + builder.addSchema(parentLines); + builder.addSchema(childLines); + builder.addSchema(grandchildLines); builder.build(true); var application = builder.application(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java index 75dcd6bc209..aec258f2df0 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java @@ -20,7 +20,7 @@ public class StemmingSettingTestCase extends AbstractSchemaTestCase { @Test public void testStemmingSettings() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/stemmingsetting.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/stemmingsetting.sd"); SDField artist = (SDField) schema.getDocument().getField("artist"); assertEquals(Stemming.SHORTEST, artist.getStemming(schema)); @@ -43,7 +43,7 @@ public class StemmingSettingTestCase extends AbstractSchemaTestCase { @Test public void requireThatStemmingIsDefaultBest() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/stemmingdefault.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/stemmingdefault.sd"); assertNull(schema.getConcreteField("my_str").getStemming()); assertEquals(Stemming.BEST, schema.getConcreteField("my_str").getStemming(schema)); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java index 34093bf72ef..c27dd9dfdfb 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java @@ -25,7 +25,7 @@ public class StructTestCase extends AbstractSchemaTestCase { @Test public void testBadStruct() throws IOException { try { - SchemaBuilder.buildFromFile("src/test/examples/badstruct.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/badstruct.sd"); fail("Should throw exception."); } catch (ParseException expected) { // success @@ -46,7 +46,7 @@ public class StructTestCase extends AbstractSchemaTestCase { */ @Test(expected = IllegalArgumentException.class) public void testStructOutsideDocumentIllegal() throws IOException, ParseException { - SchemaBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java index 7c8e806d768..086e3485962 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java @@ -39,7 +39,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SchemaBuilder.createFromString(sd, logger); + ApplicationBuilder.createFromString(sd, logger); assertTrue(logger.entries.isEmpty()); } @@ -61,7 +61,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SchemaBuilder.createFromString(sd, logger); + ApplicationBuilder.createFromString(sd, logger); assertEquals(1, logger.entries.size()); assertEquals(Level.WARNING, logger.entries.get(0).level); assertEquals("summary field 'foo2' in document summary 'foobar' references source field 'ondisk', " + @@ -89,7 +89,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SchemaBuilder.createFromString(sd, logger); + ApplicationBuilder.createFromString(sd, logger); assertTrue(logger.entries.isEmpty()); } @@ -120,7 +120,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SchemaBuilder.createFromString(sd, logger); + ApplicationBuilder.createFromString(sd, logger); assertTrue(logger.entries.isEmpty()); } @@ -156,7 +156,7 @@ public class SummaryTestCase { " }", "}"); var logger = new DeployLoggerStub(); - var search = SchemaBuilder.createFromString(sd, logger).getSchema(); + var search = ApplicationBuilder.createFromString(sd, logger).getSchema(); assertEquals(List.of(), logger.entries); var titleField = "title"; @@ -208,7 +208,7 @@ public class SummaryTestCase { "}"); var logger = new DeployLoggerStub(); try { - SchemaBuilder.createFromString(sd, logger); + ApplicationBuilder.createFromString(sd, logger); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("For schema 'music', summary class 'title2', summary field 'title': Can not use " + @@ -228,7 +228,7 @@ public class SummaryTestCase { " }" + "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SchemaBuilder.createFromStrings(logger, schema); + ApplicationBuilder.createFromStrings(logger, schema); assertEquals("document summary 'test_summary' inherits nonesuch but this is not present in schema 'test'", logger.entries.get(0).message); // fail("Expected failure"); @@ -264,7 +264,7 @@ public class SummaryTestCase { " }" + "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SchemaBuilder.createFromStrings(logger, parent, child); + ApplicationBuilder.createFromStrings(logger, parent, child); logger.entries.forEach(e -> System.out.println(e)); //assertTrue(logger.entries.isEmpty()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java index 9fdeb9ece1d..f2d78796553 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java @@ -15,14 +15,14 @@ public class UrlFieldValidationTestCase { @Test public void requireThatInheritedRiseFieldsStillCanBeInConflictButDontThrowException() throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString("search test {" + - " document test { " + - " field a type uri { indexing: attribute | summary }" + - " }" + - "}"); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema("search test {" + + " document test { " + + " field a type uri { indexing: attribute | summary }" + + " }" + + "}"); try { - builder.build(); + builder.build(true); fail("Should have caused an exception"); // success } catch (IllegalArgumentException e) { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java index 8b54455d176..a88ad929e80 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java @@ -8,7 +8,7 @@ import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.document.config.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; @@ -38,14 +38,14 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { toDir.mkdirs(); deleteContent(toDir); - SchemaBuilder builder = SchemaBuilder.createFromDirectory(searchDefRoot + dirName + "/", new MockFileRegistry(), logger, properties); + ApplicationBuilder builder = ApplicationBuilder.createFromDirectory(searchDefRoot + dirName + "/", new MockFileRegistry(), logger, properties); return derive(dirName, searchDefinitionName, properties, builder, logger); } private DerivedConfiguration derive(String dirName, String searchDefinitionName, TestProperties properties, - SchemaBuilder builder, + ApplicationBuilder builder, DeployLogger logger) throws IOException { DerivedConfiguration config = new DerivedConfiguration(builder.getSchema(searchDefinitionName), logger, @@ -57,14 +57,14 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { return export(dirName, builder, config); } - DerivedConfiguration derive(String dirName, SchemaBuilder builder, Schema schema) throws IOException { + DerivedConfiguration derive(String dirName, ApplicationBuilder builder, Schema schema) throws IOException { DerivedConfiguration config = new DerivedConfiguration(schema, builder.getRankProfileRegistry(), builder.getQueryProfileRegistry()); return export(dirName, builder, config); } - private DerivedConfiguration export(String name, SchemaBuilder builder, DerivedConfiguration config) throws IOException { + private DerivedConfiguration export(String name, ApplicationBuilder builder, DerivedConfiguration config) throws IOException { String path = exportConfig(name, config); DerivedConfiguration.exportDocuments(new DocumentManager().useV8DocManagerCfg(useV8DocManagerCfg()) .produce(builder.getModel(), new DocumentmanagerConfig.Builder()), path); @@ -114,14 +114,14 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { * Asserts config is correctly derived given a builder. * This will fail if the builder contains multiple search definitions. */ - protected DerivedConfiguration assertCorrectDeriving(SchemaBuilder builder, String dirName, DeployLogger logger) throws IOException { - builder.build(); + protected DerivedConfiguration assertCorrectDeriving(ApplicationBuilder builder, String dirName, DeployLogger logger) throws IOException { + builder.build(true); DerivedConfiguration derived = derive(dirName, null, new TestProperties(), builder, logger); assertCorrectConfigFiles(dirName); return derived; } - protected DerivedConfiguration assertCorrectDeriving(SchemaBuilder builder, Schema schema, String name) throws IOException { + protected DerivedConfiguration assertCorrectDeriving(ApplicationBuilder builder, Schema schema, String name) throws IOException { DerivedConfiguration derived = derive(name, builder, schema); assertCorrectConfigFiles(name); return derived; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java index 58a4350b73b..a272ab14dad 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.parser.ParseException; @@ -25,7 +25,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() throws IOException, ParseException { // Test attribute importing - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/simple.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/simple.sd"); // Test attribute deriving AttributeFields attributeFields = new AttributeFields(schema); @@ -71,7 +71,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void fields_in_array_of_struct_are_derived_into_array_attributes() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd"); Iterator<Attribute> attributes = new AttributeFields(schema).attributeIterator(); assertAttribute("elem_array.name", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); @@ -81,7 +81,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void fields_in_map_of_struct_are_derived_into_array_attributes() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); Iterator<Attribute> attributes = new AttributeFields(schema).attributeIterator(); assertAttribute("str_elem_map.key", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); @@ -101,7 +101,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void only_zcurve_attribute_is_derived_from_array_of_position_field() throws ParseException { - Schema schema = SchemaBuilder.createFromString( + Schema schema = ApplicationBuilder.createFromString( joinLines("search test {", " document test {", " field pos_array type array<position> {", @@ -117,7 +117,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void fields_in_map_of_primitive_are_derived_into_array_attributes() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/derived/map_attribute/test.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/derived/map_attribute/test.sd"); Iterator<Attribute> attributes = new AttributeFields(schema).attributeIterator(); assertAttribute("str_map.key", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java index 06d72bb6972..ee9a9eac02c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -20,7 +20,7 @@ public class CasingTestCase extends AbstractSchemaTestCase { @Test public void testCasing() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/casing.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/casing.sd"); assertEquals(schema.getIndex("color").getName(), "color"); assertEquals(schema.getIndex("Foo").getName(), "Foo"); assertEquals(schema.getIndex("Price").getName(), "Price"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java index 604082fb52e..237e6c8c992 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java @@ -1,11 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -20,7 +21,7 @@ public class EmptyRankProfileTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() { - Schema schema = new Schema("test"); + Schema schema = new Schema("test", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); SDDocumentType doc = new SDDocumentType("test"); schema.addDocument(doc); @@ -30,7 +31,7 @@ public class EmptyRankProfileTestCase extends AbstractSchemaTestCase { doc.addField(field); doc.addField(new SDField("c", DataType.STRING)); - schema = SchemaBuilder.buildFromRawSchema(schema, rankProfileRegistry, new QueryProfileRegistry()); + schema = ApplicationBuilder.buildFromRawSchema(schema, rankProfileRegistry, new QueryProfileRegistry()); new DerivedConfiguration(schema, rankProfileRegistry); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java index fda3e6c16c3..ddb627216b7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java @@ -1,8 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; -import com.yahoo.config.model.deploy.TestProperties; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -145,10 +144,10 @@ public class ExportingTestCase extends AbstractExportingTestCase { @Test public void testTensor2() throws IOException, ParseException { String dir = "src/test/derived/tensor2/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(dir + "first.sd"); - builder.importFile(dir + "second.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(dir + "first.sd"); + builder.addSchemaFile(dir + "second.sd"); + builder.build(true); derive("tensor2", builder, builder.getSchema("second")); assertCorrectConfigFiles("tensor2"); } @@ -170,4 +169,9 @@ public class ExportingTestCase extends AbstractExportingTestCase { assertEquals(0, logger.warnings.size()); } + @Test + public void testRankProfileModularity() throws IOException, ParseException { + assertCorrectDeriving("rankprofilemodularity"); + } + } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java index b262ef92e1a..440f067dd00 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java @@ -2,6 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; @@ -25,7 +26,7 @@ public class IdTestCase extends AbstractExportingTestCase { @Test public void testExplicitUpperCaseIdField() { - Schema schema = new Schema("test"); + Schema schema = new Schema("test", MockApplicationPackage.createEmpty()); SDDocumentType document = new SDDocumentType("test"); schema.addDocument(document); SDField uri = new SDField("URI", DataType.URI); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java index f9bd28037eb..bcf68387294 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java @@ -1,11 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; @@ -40,10 +41,10 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void requireThatIndexedStructFieldCanBeInherited() throws IOException, ParseException { String dir = "src/test/derived/inheritstruct/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(dir + "parent.sd"); - builder.importFile(dir + "child.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(dir + "parent.sd"); + builder.addSchemaFile(dir + "child.sd"); + builder.build(true); derive("inheritstruct", builder, builder.getSchema("child")); assertCorrectConfigFiles("inheritstruct"); } @@ -63,12 +64,12 @@ public class InheritanceTestCase extends AbstractExportingTestCase { List<String> files = Arrays.asList("grandparent.sd", "mother.sd", "father.sd", "child.sd"); File outDir = tmpDir.newFolder("out"); for (int startIdx = 0; startIdx < files.size(); ++startIdx) { - SchemaBuilder builder = new SchemaBuilder(); + ApplicationBuilder builder = new ApplicationBuilder(); for (int fileIdx = startIdx; fileIdx < startIdx + files.size(); ++fileIdx) { String fileName = files.get(fileIdx % files.size()); - builder.importFile(dir + fileName); + builder.addSchemaFile(dir + fileName); } - builder.build(); + builder.build(true); DocumentmanagerConfig.Builder b = new DocumentmanagerConfig.Builder(); DerivedConfiguration.exportDocuments(new DocumentManager().produce(builder.getModel(), b), outDir.getPath()); DocumentmanagerConfig dc = b.build(); @@ -110,10 +111,10 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void requireThatStructTypesAreInheritedFromParent() throws IOException, ParseException { String dir = "src/test/derived/inheritfromparent/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(dir + "parent.sd"); - builder.importFile(dir + "child.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(dir + "parent.sd"); + builder.addSchemaFile(dir + "child.sd"); + builder.build(true); derive("inheritfromparent", builder, builder.getSchema("child")); assertCorrectConfigFiles("inheritfromparent"); } @@ -121,11 +122,11 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void requireThatStructTypesAreInheritedFromGrandParent() throws IOException, ParseException { String dir = "src/test/derived/inheritfromgrandparent/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(dir + "grandparent.sd"); - builder.importFile(dir + "parent.sd"); - builder.importFile(dir + "child.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(dir + "grandparent.sd"); + builder.addSchemaFile(dir + "parent.sd"); + builder.addSchemaFile(dir + "child.sd"); + builder.build(true); derive("inheritfromgrandparent", builder, builder.getSchema("child")); assertCorrectConfigFiles("inheritfromgrandparent"); } @@ -133,12 +134,12 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void testInheritance() throws IOException, ParseException { String dir = "src/test/derived/inheritance/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(dir + "grandparent.sd"); - builder.importFile(dir + "father.sd"); - builder.importFile(dir + "mother.sd"); - builder.importFile(dir + "child.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(dir + "grandparent.sd"); + builder.addSchemaFile(dir + "father.sd"); + builder.addSchemaFile(dir + "mother.sd"); + builder.addSchemaFile(dir + "child.sd"); + builder.build(true); derive("inheritance", builder, builder.getSchema("child")); assertCorrectConfigFiles("inheritance"); } @@ -146,7 +147,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void testIndexSettingInheritance() { SDDocumentType parent = new SDDocumentType("parent"); - Schema parentSchema = new Schema("parent"); + Schema parentSchema = new Schema("parent", MockApplicationPackage.createEmpty()); parentSchema.addDocument(parent); SDField prefixed = parent.addField("prefixed", DataType.STRING); prefixed.parseIndexingScript("{ index }"); @@ -154,7 +155,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { SDDocumentType child = new SDDocumentType("child"); child.inherit(parent); - Schema childSchema = new Schema("child"); + Schema childSchema = new Schema("child", MockApplicationPackage.createEmpty()); childSchema.addDocument(child); prefixed = (SDField)child.getField("prefixed"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java index f8f1bf9e4f1..1e7dd3a2405 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java @@ -2,12 +2,13 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.processing.Processing; @@ -30,7 +31,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { */ @Test public void testLiteralBoost() { - Schema schema = new Schema("literalboost"); + Schema schema = new Schema("literalboost", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); SDDocumentType document = new SDDocumentType("literalboost"); schema.addDocument(document); @@ -63,7 +64,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { */ @Test public void testNonDefaultRankLiteralBoost() { - Schema schema = new Schema("literalboost"); + Schema schema = new Schema("literalboost", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); SDDocumentType document = new SDDocumentType("literalboost"); schema.addDocument(document); @@ -73,7 +74,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { rankProfileRegistry.add(other); other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333)); - schema = SchemaBuilder.buildFromRawSchema(schema, rankProfileRegistry, new QueryProfileRegistry()); + schema = ApplicationBuilder.buildFromRawSchema(schema, rankProfileRegistry, new QueryProfileRegistry()); DerivedConfiguration derived = new DerivedConfiguration(schema, rankProfileRegistry); // Check il script addition @@ -89,7 +90,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { /** Tests literal boosts in two fields going to the same index */ @Test public void testTwoLiteralBoostFields() { - Schema schema = new Schema("msb"); + Schema schema = new Schema("msb", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); SDDocumentType document = new SDDocumentType("msb"); schema.addDocument(document); @@ -100,7 +101,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { field2.parseIndexingScript("{ summary | index }"); field2.setLiteralBoost(20); - schema = SchemaBuilder.buildFromRawSchema(schema, rankProfileRegistry, new QueryProfileRegistry()); + schema = ApplicationBuilder.buildFromRawSchema(schema, rankProfileRegistry, new QueryProfileRegistry()); new DerivedConfiguration(schema, rankProfileRegistry); assertIndexing(Arrays.asList("clear_state | guard { input title | tokenize normalize stem:\"BEST\" | summary title | index title; }", "clear_state | guard { input body | tokenize normalize stem:\"BEST\" | summary body | index body; }", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.java index 9ad6dfbb972..53bf55fc73f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; import java.io.IOException; @@ -16,8 +16,8 @@ public class MailTestCase extends AbstractExportingTestCase { @Test public void testMail() throws IOException, ParseException { String dir = "src/test/derived/mail/"; - SchemaBuilder sb = new SchemaBuilder(); - sb.importFile(dir + "mail.sd"); + ApplicationBuilder sb = new ApplicationBuilder(); + sb.addSchemaFile(dir + "mail.sd"); assertCorrectDeriving(sb, dir, new TestableDeployLogger()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java index c7297c41c62..a458036a03f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.io.IOUtils; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -19,10 +19,10 @@ public class SchemaInheritanceTestCase extends AbstractExportingTestCase { @Test public void testIt() throws IOException, ParseException { try { - SchemaBuilder builder = SchemaBuilder.createFromDirectory("src/test/derived/schemainheritance/", - new MockFileRegistry(), - new TestableDeployLogger(), - new TestProperties()); + ApplicationBuilder builder = ApplicationBuilder.createFromDirectory("src/test/derived/schemainheritance/", + new MockFileRegistry(), + new TestableDeployLogger(), + new TestProperties()); derive("schemainheritance", builder, builder.getSchema("child")); assertCorrectConfigFiles("schemainheritance"); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java index b3f2fb62ac2..34d33a00d9e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.ReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.DocumentReference; @@ -62,7 +63,7 @@ public class SchemaOrdererTestCase extends AbstractSchemaTestCase { } private static Schema createSchema(String name, Map<String, Schema> schemas) { - Schema schema = new Schema(name); + Schema schema = new Schema(name, MockApplicationPackage.createEmpty()); SDDocumentType document = new SDDocumentType(name); document.setDocumentReferences(new DocumentReferences(emptyMap())); schema.addDocument(document); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java index c0f2b6887d2..d89e5f2c957 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -19,10 +19,10 @@ public class SimpleInheritTestCase extends AbstractExportingTestCase { String name = "emptychild"; final String expectedResultsDirName = "src/test/derived/" + name + "/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(expectedResultsDirName + "parent.sd"); - builder.importFile(expectedResultsDirName + "child.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(expectedResultsDirName + "parent.sd"); + builder.addSchemaFile(expectedResultsDirName + "child.sd"); + builder.build(true); Schema schema = builder.getSchema("child"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java index b2c2a54ce5e..1f6c70c9383 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Rule; @@ -31,8 +31,8 @@ public class StructInheritanceTestCase extends AbstractExportingTestCase { @Test public void requireThatStructCanInherit() throws IOException, ParseException { String dir = "src/test/derived/structinheritance/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(dir + "simple.sd"); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(dir + "simple.sd"); builder.build(false); derive("structinheritance", builder, builder.getSchema("simple")); assertCorrectConfigFiles("structinheritance"); @@ -43,9 +43,9 @@ public class StructInheritanceTestCase extends AbstractExportingTestCase { exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage("cannot inherit from base and redeclare field name"); String dir = "src/test/derived/structinheritance/"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(dir + "bad.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(dir + "bad.sd"); + builder.build(true); derive("structinheritance", builder, builder.getSchema("bad")); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java index 4994cffb92a..c0fa3e8311f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.searchdefinition.*; import com.yahoo.vespa.config.search.SummarymapConfig; import com.yahoo.config.model.application.provider.BaseDeployLogger; @@ -29,7 +30,7 @@ import static org.junit.Assert.assertTrue; public class SummaryMapTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/simple.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/simple.sd"); SummaryMap summaryMap=new SummaryMap(schema); Iterator transforms=summaryMap.resultTransformIterator(); @@ -73,7 +74,7 @@ public class SummaryMapTestCase extends AbstractSchemaTestCase { } @Test public void testPositionDeriving() { - Schema schema = new Schema("store"); + Schema schema = new Schema("store", MockApplicationPackage.createEmpty()); SDDocumentType document = new SDDocumentType("store"); schema.addDocument(document); String fieldName = "location"; @@ -147,7 +148,7 @@ public class SummaryMapTestCase extends AbstractSchemaTestCase { @Test public void testFailOnSummaryFieldSourceCollision() { try { - SchemaBuilder.buildFromFile("src/test/examples/summaryfieldcollision.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/summaryfieldcollision.sd"); } catch (Exception e) { assertTrue(e.getMessage().matches(".*equally named field.*")); } @@ -189,13 +190,13 @@ public class SummaryMapTestCase extends AbstractSchemaTestCase { } private Schema buildSearch(String field) throws ParseException { - var builder = new SchemaBuilder(new RankProfileRegistry()); - builder.importString(joinLines("search test {", - " document test {", - field, - " }", - "}")); - builder.build(); + var builder = new ApplicationBuilder(new RankProfileRegistry()); + builder.addSchema(joinLines("search test {", + " document test {", + field, + " }", + "}")); + builder.build(true); return builder.getSchema(); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java index c996fb0c1b9..9a36ef90cd7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.search.SummaryConfig; @@ -35,7 +35,7 @@ public class SummaryTestCase extends AbstractSchemaTestCase { " }", " }", "}"); - Schema schema = SchemaBuilder.createFromString(sd).getSchema(); + Schema schema = ApplicationBuilder.createFromString(sd).getSchema(); SummaryClass summary = new SummaryClass(schema, schema.getSummary("default"), new BaseDeployLogger()); assertEquals(SummaryClassField.Type.RAW, summary.getField("raw_field").getType()); } @@ -50,14 +50,14 @@ public class SummaryTestCase extends AbstractSchemaTestCase { " }", " }", "}"); - Schema schema = SchemaBuilder.createFromString(sd).getSchema(); + Schema schema = ApplicationBuilder.createFromString(sd).getSchema(); SummaryClass summary = new SummaryClass(schema, schema.getSummary("default"), new BaseDeployLogger()); assertEquals(SummaryClassField.Type.DATA, summary.getField("raw_field").getType()); } @Test public void testDeriving() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/simple.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/simple.sd"); SummaryClass summary = new SummaryClass(schema, schema.getSummary("default"), new BaseDeployLogger()); assertEquals("default", summary.getName()); @@ -134,22 +134,22 @@ public class SummaryTestCase extends AbstractSchemaTestCase { } private static Schema buildCampaignAdModel() throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString("search campaign { document campaign {} }"); - builder.importString(joinLines("search ad {", - " document ad {", - " field campaign_ref type reference<campaign> {", - " indexing: summary | attribute", - " }", - " field other_campaign_ref type reference<campaign> {", - " indexing: summary | attribute", - " }", - " }", - " document-summary my_summary {", - " summary other_campaign_ref type reference<campaign> {}", - " }", - "}")); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema("search campaign { document campaign {} }"); + builder.addSchema(joinLines("search ad {", + " document ad {", + " field campaign_ref type reference<campaign> {", + " indexing: summary | attribute", + " }", + " field other_campaign_ref type reference<campaign> {", + " indexing: summary | attribute", + " }", + " }", + " document-summary my_summary {", + " summary other_campaign_ref type reference<campaign> {}", + " }", + "}")); + builder.build(true); return builder.getSchema("ad"); } @@ -168,7 +168,7 @@ public class SummaryTestCase extends AbstractSchemaTestCase { " summary foo type string {}", " }", "}"); - var search = SchemaBuilder.createFromString(sd).getSchema(); + var search = ApplicationBuilder.createFromString(sd).getSchema(); assertOmitSummaryFeatures(true, search, "bar"); assertOmitSummaryFeatures(false, search, "baz"); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.java index c3a78bab441..4e629fcb4d8 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -13,20 +13,22 @@ import java.io.IOException; * @author arnej27959 */ public class TwoStreamingStructsTestCase extends AbstractExportingTestCase { + @Test public void testTwoStreamingStructsExporting() throws ParseException, IOException { String root = "src/test/derived/twostreamingstructs"; - SchemaBuilder builder = new SchemaBuilder(); - builder.importFile(root + "/streamingstruct.sd"); - builder.importFile(root + "/whatever.sd"); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchemaFile(root + "/streamingstruct.sd"); + builder.addSchemaFile(root + "/whatever.sd"); + builder.build(true); assertCorrectDeriving(builder, builder.getSchema("streamingstruct"), root); - builder = new SchemaBuilder(); - builder.importFile(root + "/streamingstruct.sd"); - builder.importFile(root + "/whatever.sd"); - builder.build(); + builder = new ApplicationBuilder(); + builder.addSchemaFile(root + "/streamingstruct.sd"); + builder.addSchemaFile(root + "/whatever.sd"); + builder.build(true); assertCorrectDeriving(builder, builder.getSchema("streamingstruct"), root); } + } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java index 13289d72884..dbb32e61144 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java @@ -2,6 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; @@ -25,7 +26,7 @@ public class TypeConversionTestCase extends AbstractSchemaTestCase { /** Tests that exact-string stuff is not spilled over to the default index */ @Test public void testExactStringToStringTypeConversion() { - Schema schema = new Schema("test"); + Schema schema = new Schema("test", MockApplicationPackage.createEmpty()); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(schema); SDDocumentType document = new SDDocumentType("test"); schema.addDocument(document); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java index 138992477c0..5ab5a8057e8 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java @@ -24,7 +24,7 @@ public class VsmFieldsTestCase { @SuppressWarnings("deprecation") @Test public void reference_type_field_is_unsearchable() { - Schema schema = new Schema("test", new Application(MockApplicationPackage.createEmpty()), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); + Schema schema = new Schema("test", MockApplicationPackage.createEmpty(), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); schema.addDocument(new SDDocumentType("test")); SDField refField = new TemporarySDField("ref_field", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("parent_type"))); refField.parseIndexingScript("{ summary }"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java index 481a4db11ec..99692e70041 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.document; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,7 +17,7 @@ public class ComplexAttributeFieldUtilsTestCase { private final ImmutableSDField field; FixtureBase(String fieldName, String sdContent) throws ParseException { - Schema schema = SchemaBuilder.createFromString(sdContent).getSchema(); + Schema schema = ApplicationBuilder.createFromString(sdContent).getSchema(); field = schema.getConcreteField(fieldName); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java index 715b7b803e2..9ca97f4dbc7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java @@ -48,7 +48,7 @@ public class AddAttributeTransformToSummaryOfImportedFieldsTest { } private static Schema createSearch(String documentType) { - return new Schema(documentType, new Application(MockApplicationPackage.createEmpty()), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); + return new Schema(documentType, MockApplicationPackage.createEmpty(), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); } private static Schema createSearchWithDocument(String documentName) { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.java index 6a736a5331e..534c82157e4 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.processing; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import java.io.IOException; @@ -14,13 +14,13 @@ import static org.junit.Assert.*; public abstract class AssertSearchBuilder { public static void assertBuilds(String searchDefinitionFileName) throws IOException, ParseException { - assertNotNull(SchemaBuilder.buildFromFile(searchDefinitionFileName)); + assertNotNull(ApplicationBuilder.buildFromFile(searchDefinitionFileName)); } public static void assertBuildFails(String searchDefinitionFileName, String expectedException) throws IOException, ParseException { try { - SchemaBuilder.buildFromFile(searchDefinitionFileName); + ApplicationBuilder.buildFromFile(searchDefinitionFileName); fail(searchDefinitionFileName); } catch (IllegalArgumentException e) { assertEquals(expectedException, e.getMessage()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java index f1aa64c1a60..67b369fd951 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.parser.ParseException; @@ -20,7 +20,7 @@ import static org.junit.Assert.assertFalse; public class AttributesExactMatchTestCase extends AbstractSchemaTestCase { @Test public void testAttributesExactMatch() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/attributesexactmatch.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/attributesexactmatch.sd"); assertEquals(schema.getConcreteField("color").getMatching().getType(), Matching.Type.EXACT); assertEquals(schema.getConcreteField("artist").getMatching().getType(), Matching.Type.WORD); assertEquals(schema.getConcreteField("drummer").getMatching().getType(), Matching.Type.WORD); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java index f74e46d92dc..efec9206ed9 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.processing; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -31,7 +31,7 @@ public class BoldingTestCase extends AbstractSchemaTestCase { @Test public void testBoldOnNonString() throws ParseException { try { - SchemaBuilder.createFromString(boldonnonstring); + ApplicationBuilder.createFromString(boldonnonstring); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("'bolding: on' for non-text field 'year4' (datatype int (code: 0)) is not allowed", @@ -52,7 +52,7 @@ public class BoldingTestCase extends AbstractSchemaTestCase { @Test public void testBoldOnArray() throws ParseException { try { - SchemaBuilder.createFromString(boldonarray); + ApplicationBuilder.createFromString(boldonarray); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("'bolding: on' for non-text field 'myarray' (datatype Array<string> (code: -1486737430)) is not allowed", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java index 342ff4ba2d4..db27bbbb84d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; -import static com.yahoo.searchdefinition.SchemaBuilder.createFromString; +import static com.yahoo.searchdefinition.ApplicationBuilder.createFromString; import static com.yahoo.config.model.test.TestUtil.joinLines; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java index 6f8ab24de8e..a17992fad18 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.test.TestUtil; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.document.Case; import com.yahoo.searchdefinition.document.Dictionary; @@ -30,7 +30,7 @@ public class DictionaryTestCase { return builder.build(); } private Schema createSearch(String def) throws ParseException { - SchemaBuilder sb = SchemaBuilder.createFromString(def); + ApplicationBuilder sb = ApplicationBuilder.createFromString(def); return sb.getSchema(); } @Test @@ -196,7 +196,7 @@ public class DictionaryTestCase { " }", "}"); try { - SchemaBuilder sb = SchemaBuilder.createFromString(def); + ApplicationBuilder sb = ApplicationBuilder.createFromString(def); fail("Controlling dictionary for non-numeric fields are not yet supported."); } catch (IllegalArgumentException e) { assertEquals("For schema 'test', field 'n1': You can only specify 'dictionary:' for numeric or string fields", e.getMessage()); @@ -214,7 +214,7 @@ public class DictionaryTestCase { " }", "}"); try { - SchemaBuilder sb = SchemaBuilder.createFromString(def); + ApplicationBuilder sb = ApplicationBuilder.createFromString(def); fail("Controlling dictionary for non-fast-search fields are not allowed."); } catch (IllegalArgumentException e) { assertEquals("For schema 'test', field 'n1': You must specify 'attribute:fast-search' to allow dictionary control", e.getMessage()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java index 03125c48d1d..b03aff455c5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -43,15 +43,15 @@ public class DisallowComplexMapAndWsetKeyTypesTestCase { private void testFieldType(String fieldType) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " struct mystruct {}\n" + " field a type " + fieldType + " {}\n" + " }\n" + "}\n"); - builder.build(); + builder.build(true); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java index dd958fb34cd..0c25cef49a1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.test.TestUtil; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Rule; import org.junit.Test; @@ -20,15 +20,15 @@ public class FastAccessValidatorTest { @Test public void throws_exception_on_incompatible_use_of_fastaccess() throws ParseException { - SchemaBuilder builder = new SchemaBuilder(new RankProfileRegistry()); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(new RankProfileRegistry()); + builder.addSchema( TestUtil.joinLines( "schema parent {", " document parent {", " field int_field type int { indexing: attribute }", " }", "}")); - builder.importString( + builder.addSchema( TestUtil.joinLines( "schema test {", " document test { ", @@ -55,7 +55,7 @@ public class FastAccessValidatorTest { "For schema 'test': The following attributes have a type that is incompatible " + "with fast-access: predicate_attribute, tensor_attribute, reference_attribute. " + "Predicate, tensor and reference attributes are incompatible with fast-access."); - builder.build(); + builder.build(true); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java index 43077fadfcd..b0b9ce81cc7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -18,7 +18,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatExtraFieldsAreIncluded() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/extrafield.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/extrafield.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -30,7 +30,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatSummaryFieldsAreIncluded() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -43,7 +43,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatBoldedSummaryFieldsAreIncluded() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -57,7 +57,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatUntransformedSummaryFieldsAreIgnored() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -70,7 +70,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatDynamicSummaryFieldsAreIgnored() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/dynamicsummaryfields.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/dynamicsummaryfields.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -82,9 +82,9 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatDerivedConfigurationWorks() throws IOException, ParseException { - SchemaBuilder sb = new SchemaBuilder(); - sb.importFile("src/test/examples/nextgen/simple.sd"); - sb.build(); + ApplicationBuilder sb = new ApplicationBuilder(); + sb.addSchemaFile("src/test/examples/nextgen/simple.sd"); + sb.build(true); assertNotNull(sb.getSchema()); new DerivedConfiguration(sb.getSchema(), sb.getRankProfileRegistry()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java index bd645b68728..443eff07f41 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.document.*; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -16,7 +16,7 @@ import static org.junit.Assert.*; public class ImplicitStructTypesTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitStructsAreCreated() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -25,7 +25,7 @@ public class ImplicitStructTypesTestCase extends AbstractSchemaTestCase { } @Test public void testRequireThatImplicitStructsAreUsed() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/implicitstructtypes.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/implicitstructtypes.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java index 9c1e5d0d8d7..cc2bc7d7bf6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.SummaryTransform; import org.junit.Test; @@ -29,7 +29,7 @@ public class ImplicitSummariesTestCase { LogHandler log = new LogHandler(); Logger.getLogger("").addHandler(log); - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/implicitsummaries_attribute.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/implicitsummaries_attribute.sd"); assertNotNull(schema); assertTrue(log.records.isEmpty()); } @@ -60,19 +60,19 @@ public class ImplicitSummariesTestCase { @Test public void attribute_combiner_transform_is_set_on_array_of_struct_with_only_struct_field_attributes() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd"); assertEquals(SummaryTransform.ATTRIBUTECOMBINER, schema.getSummaryField("elem_array").getTransform()); } @Test public void attribute_combiner_transform_is_set_on_map_of_struct_with_only_struct_field_attributes() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); assertEquals(SummaryTransform.ATTRIBUTECOMBINER, schema.getSummaryField("str_elem_map").getTransform()); } @Test public void attribute_combiner_transform_is_not_set_when_map_of_struct_has_some_struct_field_attributes() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); assertEquals(SummaryTransform.NONE, schema.getSummaryField("int_elem_map").getTransform()); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java index 44b1d9387f1..175b8d6fe1e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.DocumentSummary; @@ -17,7 +17,7 @@ public class ImplicitSummaryFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/implicitsummaryfields.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/implicitsummaryfields.sd"); assertNotNull(schema); DocumentSummary docsum = schema.getSummary("default"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java index 6eab1dddc79..b15b81b717d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.document.ImportedComplexField; import com.yahoo.searchdefinition.document.ImportedField; @@ -68,21 +68,21 @@ public class ImportedFieldsTestCase { } private static Schema buildAdSearch(String sdContent) throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "schema campaign {", " document campaign {", " field budget type int { indexing: attribute }", " }", "}")); - builder.importString(joinLines( + builder.addSchema(joinLines( "schema person {", " document person {", " field name type string { indexing: attribute }", " }", "}")); - builder.importString(sdContent); - builder.build(); + builder.addSchema(sdContent); + builder.build(true); return builder.getSchema("ad"); } @@ -312,19 +312,19 @@ public class ImportedFieldsTestCase { } private static Schema buildChildSearch(String parentSdContent, String sdContent) throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(parentSdContent); - builder.importString(sdContent); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(parentSdContent); + builder.addSchema(sdContent); + builder.build(true); return builder.getSchema("child"); } private static Schema buildChildSearch(String grandParentSdContent, String parentSdContent, String sdContent) throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(grandParentSdContent); - builder.importString(parentSdContent); - builder.importString(sdContent); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(grandParentSdContent); + builder.addSchema(parentSdContent); + builder.addSchema(sdContent); + builder.build(true); return builder.getSchema("child"); } @@ -488,41 +488,41 @@ public class ImportedFieldsTestCase { assertTrue(attrs.containsAttribute("entries.value")); } - private SchemaBuilder buildParentsUsingInheritance() throws ParseException { - var builder = new SchemaBuilder(); - builder.importString(joinLines("schema parent_a {", - "document parent_a {", - " struct Entry {", - " field key type string {}", - " field value type string {}", - " }", - " field entries type array<Entry> {", - " indexing: summary", - " struct-field key { indexing: attribute }", - " struct-field value { indexing: attribute }", - " }", - "}", - "}")); - - builder.importString(joinLines("schema parent_b {", - "document parent_b inherits parent_a {", - "}", - "}")); - - builder.importString(joinLines("schema child {", - "document child {", - " field ref_parent_a type reference<parent_a> {", - " indexing: attribute", - " }", - " field ref_parent_b type reference<parent_b> {", - " indexing: attribute", - " }", - "}", - "import field ref_parent_a.entries as entries_from_a {}", - "import field ref_parent_b.entries as entries_from_b {}", - "}")); - - builder.build(); + private ApplicationBuilder buildParentsUsingInheritance() throws ParseException { + var builder = new ApplicationBuilder(); + builder.addSchema(joinLines("schema parent_a {", + "document parent_a {", + " struct Entry {", + " field key type string {}", + " field value type string {}", + " }", + " field entries type array<Entry> {", + " indexing: summary", + " struct-field key { indexing: attribute }", + " struct-field value { indexing: attribute }", + " }", + "}", + "}")); + + builder.addSchema(joinLines("schema parent_b {", + "document parent_b inherits parent_a {", + "}", + "}")); + + builder.addSchema(joinLines("schema child {", + "document child {", + " field ref_parent_a type reference<parent_a> {", + " indexing: attribute", + " }", + " field ref_parent_b type reference<parent_b> {", + " indexing: attribute", + " }", + "}", + "import field ref_parent_a.entries as entries_from_a {}", + "import field ref_parent_b.entries as entries_from_b {}", + "}")); + + builder.build(true); return builder; } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java index 3105e3c7efd..9e4ba1c6728 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java @@ -2,11 +2,12 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.BooleanIndexDefinition; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -120,7 +121,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { "clear_state | guard { input smallattribute | attribute smallattribute; }", "clear_state | guard { input title | tokenize normalize stem:\"BEST\" | summary title | index title; }", "clear_state | guard { input title . \" \" . input category | tokenize | summary exact | index exact; }"), - SchemaBuilder.buildFromFile("src/test/examples/simple.sd")); + ApplicationBuilder.buildFromFile("src/test/examples/simple.sd")); } @Test @@ -129,7 +130,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { Arrays.asList("clear_state | guard { input title_src | lowercase | normalize | " + " tokenize | index title; }", "clear_state | guard { input title_src | summary title_s; }"), - SchemaBuilder.buildFromFile("src/test/examples/indexrewrite.sd")); + ApplicationBuilder.buildFromFile("src/test/examples/indexrewrite.sd")); } @Test @@ -154,7 +155,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { private static ScriptExpression processField(SDField unprocessedField) { SDDocumentType sdoc = new SDDocumentType("test"); sdoc.addField(unprocessedField); - Schema schema = new Schema("test"); + Schema schema = new Schema("test", MockApplicationPackage.createEmpty()); schema.addDocument(sdoc); new Processing().process(schema, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true, false, Set.of()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java index 5b5c5cedc0d..74a8cdfdb6a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.processing; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.derived.AbstractExportingTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -64,7 +64,7 @@ public class IndexingValidationTestCase extends AbstractExportingTestCase { assertIndexing( Arrays.asList("clear_state | guard { input my_index | tokenize normalize stem:\"BEST\" | index my_index | summary my_index }", "clear_state | guard { input my_input | tokenize normalize stem:\"BEST\" | index my_extra | summary my_extra }"), - SchemaBuilder.buildFromFile("src/test/examples/indexing_extra.sd")); + ApplicationBuilder.buildFromFile("src/test/examples/indexing_extra.sd")); } @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java index 4b13590c777..2465839b72b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; @@ -24,7 +24,7 @@ public class IntegerIndex2AttributeTestCase extends AbstractSchemaTestCase { @Test public void testIntegerIndex2Attribute() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/integerindex2attribute.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/integerindex2attribute.sd"); new IntegerIndex2Attribute(schema, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true, false); SDField f; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java index 7eea2fca0e6..b48927d58a3 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -175,18 +175,18 @@ public class MatchedElementsOnlyResolverTestCase { } private Schema buildSearch(String field, String summary) throws ParseException { - var builder = new SchemaBuilder(new RankProfileRegistry()); - builder.importString(joinLines("search test {", - " document test {", - " struct elem {", - " field name type string {}", - " field weight type int {}", - " }", - field, - " }", - summary, - "}")); - builder.build(); + var builder = new ApplicationBuilder(new RankProfileRegistry()); + builder.addSchema(joinLines("search test {", + " document test {", + " struct elem {", + " field name type string {}", + " field weight type int {}", + " }", + field, + " }", + summary, + "}")); + builder.build(true); return builder.getSchema(); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java index 1adb909ff21..7169a97f3fc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; @@ -25,7 +25,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testNGram() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/ngram.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/ngram.sd"); assertNotNull(schema); SDField gram1 = schema.getConcreteField("gram_1"); @@ -55,7 +55,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testInvalidNGramSetting1() throws IOException, ParseException { try { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/invalidngram1.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/invalidngram1.sd"); fail("Should cause an exception"); } catch (IllegalArgumentException e) { @@ -66,7 +66,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testInvalidNGramSetting2() throws IOException, ParseException { try { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/invalidngram2.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/invalidngram2.sd"); fail("Should cause an exception"); } catch (IllegalArgumentException e) { @@ -77,7 +77,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testInvalidNGramSetting3() throws IOException, ParseException { try { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/invalidngram3.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/invalidngram3.sd"); fail("Should cause an exception"); } catch (IllegalArgumentException e) { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java index 5fce16f381a..02b5997471b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; import static com.yahoo.config.model.test.TestUtil.joinLines; -import static com.yahoo.searchdefinition.SchemaBuilder.createFromString; +import static com.yahoo.searchdefinition.ApplicationBuilder.createFromString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java index 74fa7c72554..b14c7287537 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java @@ -23,7 +23,6 @@ import com.yahoo.searchdefinition.document.TemporarySDField; */ public class ParentChildSearchModel { - private final Application application = new Application(MockApplicationPackage.createEmpty()); public Schema parentSchema; public Schema childSchema; @@ -33,7 +32,7 @@ public class ParentChildSearchModel { } protected Schema createSearch(String name) { - Schema result = new Schema(name, application, new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); + Schema result = new Schema(name, MockApplicationPackage.createEmpty(), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); result.addDocument(new SDDocumentType(name)); return result; } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java index c3beeeaa17e..eaf38396efc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.PositionDataType; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.FieldSet; import com.yahoo.vespa.documentmodel.SummaryField; @@ -27,7 +27,7 @@ public class PositionTestCase { @Test public void inherited_position_zcurve_field_is_not_added_to_document_fieldset() throws Exception { - SchemaBuilder sb = SchemaBuilder.createFromFiles(Arrays.asList( + ApplicationBuilder sb = ApplicationBuilder.createFromFiles(Arrays.asList( "src/test/examples/position_base.sd", "src/test/examples/position_inherited.sd")); @@ -38,7 +38,7 @@ public class PositionTestCase { @Test public void requireThatPositionCanBeAttribute() throws Exception { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_attribute.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/position_attribute.sd"); assertNull(schema.getAttribute("pos")); assertNull(schema.getAttribute("pos.x")); assertNull(schema.getAttribute("pos.y")); @@ -50,7 +50,7 @@ public class PositionTestCase { @Test public void requireThatPositionCanNotBeIndex() throws Exception { try { - SchemaBuilder.buildFromFile("src/test/examples/position_index.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/position_index.sd"); fail(); } catch (IllegalArgumentException e) { assertEquals("For schema 'position_index', field 'pos': Indexing of data type 'position' is not " + @@ -60,7 +60,7 @@ public class PositionTestCase { @Test public void requireThatSummaryAloneDoesNotCreateZCurve() throws Exception { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_summary.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/position_summary.sd"); assertNull(schema.getAttribute("pos")); assertNull(schema.getAttribute("pos.x")); assertNull(schema.getAttribute("pos.y")); @@ -79,7 +79,7 @@ public class PositionTestCase { @Test public void requireThatExtraFieldCanBePositionAttribute() throws Exception { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_extra.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/position_extra.sd"); assertNull(schema.getAttribute("pos_ext")); assertNull(schema.getAttribute("pos_ext.x")); assertNull(schema.getAttribute("pos_ext.y")); @@ -90,7 +90,7 @@ public class PositionTestCase { @Test public void requireThatPositionArrayIsSupported() throws Exception { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_array.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/position_array.sd"); assertNull(schema.getAttribute("pos")); assertNull(schema.getAttribute("pos.x")); assertNull(schema.getAttribute("pos.y")); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java index 87dd92f41d9..3a0ceebcb0a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,6 +17,6 @@ import java.io.IOException; public class RankModifierTestCase extends AbstractSchemaTestCase { @Test public void testLiteral() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/rankmodifier/literal.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/rankmodifier/literal.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java index 2707f60f828..2d0bdb58122 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java @@ -13,7 +13,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; import ai.vespa.rankingexpression.importer.onnx.OnnxImporter; @@ -68,7 +68,7 @@ class RankProfileSearchFixture { String rankProfiles, String constant, String field) throws ParseException { this.queryProfileRegistry = queryProfileRegistry; - SchemaBuilder builder = new SchemaBuilder(applicationpackage, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); + ApplicationBuilder builder = new ApplicationBuilder(applicationpackage, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); String sdContent = "search test {\n" + " " + (constant != null ? constant : "") + "\n" + " document test {\n" + @@ -77,8 +77,8 @@ class RankProfileSearchFixture { rankProfiles + "\n" + "}"; - builder.importString(sdContent); - builder.build(); + builder.addSchema(sdContent); + builder.build(true); schema = builder.getSchema(); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java index b1624b7fd7e..0ab7406b5b1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile.RankProperty; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -21,10 +21,10 @@ public class RankPropertyVariablesTestCase extends AbstractSchemaTestCase { @Test public void testRankPropVariables() throws IOException, ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/rankpropvars.sd", - new BaseDeployLogger(), - rankProfileRegistry, - new QueryProfileRegistry()); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/rankpropvars.sd", + new BaseDeployLogger(), + rankProfileRegistry, + new QueryProfileRegistry()); assertRankPropEquals(rankProfileRegistry.get(schema, "other").getRankProperties(), "$testvar1", "foo"); assertRankPropEquals(rankProfileRegistry.get(schema, "other").getRankProperties(), "$testvar_2", "bar"); assertRankPropEquals(rankProfileRegistry.get(schema, "other").getRankProperties(), "$testvarOne23", "baz"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java index 4f18c9b68fd..7f5e8f8753a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.search.query.profile.types.QueryProfileType; import com.yahoo.search.query.profile.types.TensorFieldType; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode; import com.yahoo.tensor.TensorType; import com.yahoo.yolean.Exceptions; @@ -33,8 +33,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorFirstPhaseMustProduceDouble() throws Exception { try { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[10],y[3]) {", @@ -48,7 +48,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.build(); + builder.build(true); fail("Expected exception"); } catch (IllegalArgumentException expected) { @@ -61,8 +61,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorFirstPhaseFromConstantMustProduceDouble() throws Exception { try { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(d0[3]) {", @@ -96,7 +96,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.build(); + builder.build(true); fail("Expected exception"); } catch (IllegalArgumentException expected) { @@ -110,8 +110,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorSecondPhaseMustProduceDouble() throws Exception { try { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[10],y[3]) {", @@ -128,7 +128,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.build(); + builder.build(true); fail("Expected exception"); } catch (IllegalArgumentException expected) { @@ -140,8 +140,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorConditionsMustHaveTypeCompatibleBranches() throws Exception { try { - SchemaBuilder schemaBuilder = new SchemaBuilder(); - schemaBuilder.importString(joinLines( + ApplicationBuilder schemaBuilder = new ApplicationBuilder(); + schemaBuilder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[10],y[5]) {", @@ -158,7 +158,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - schemaBuilder.build(); + schemaBuilder.build(true); fail("Expected exception"); } catch (IllegalArgumentException expected) { @@ -172,8 +172,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testFunctionInvocationTypes() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[10],y[3]) {", @@ -194,7 +194,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.build(); + builder.build(true); RankProfile profile = builder.getRankProfileRegistry().get(builder.getSchema(), "my_rank_profile"); assertEquals(TensorType.fromSpec("tensor(x[10],y[3])"), @@ -205,8 +205,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testTensorFunctionInvocationTypes_Nested() throws Exception { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[10],y[1]) {", @@ -236,7 +236,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.build(); + builder.build(true); RankProfile profile = builder.getRankProfileRegistry().get(builder.getSchema(), "my_rank_profile"); assertEquals(TensorType.fromSpec("tensor(x[10],y[1])"), @@ -247,8 +247,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testAttributeInvocationViaBoundIdentifier() throws Exception { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search newsarticle {", " document newsarticle {", " field title type string {", @@ -280,14 +280,14 @@ public class RankingExpressionTypeResolverTestCase { " first-phase { expression: commonfirstphase(eustaticrank) }", " }", "}")); - builder.build(); + builder.build(true); RankProfile profile = builder.getRankProfileRegistry().get(builder.getSchema(), "eurank"); } @Test public void testTensorFunctionInvocationTypes_NestedSameName() throws Exception { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search test {", " document test { ", " field a type tensor(x[10],y[1]) {", @@ -320,7 +320,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.build(); + builder.build(true); RankProfile profile = builder.getRankProfileRegistry().get(builder.getSchema(), "my_rank_profile"); assertEquals(TensorType.fromSpec("tensor(x[10],y[1])"), @@ -331,8 +331,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testTensorFunctionInvocationTypes_viaFuncWithExpr() throws Exception { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search test {", " document test {", " field t1 type tensor<float>(y{}) { indexing: attribute | summary }", @@ -345,7 +345,7 @@ public class RankingExpressionTypeResolverTestCase { " summary-features { test_func_via_func_with_expr }", " }", "}")); - builder.build(); + builder.build(true); RankProfile profile = builder.getRankProfileRegistry().get(builder.getSchema(), "test"); assertEquals(TensorType.fromSpec("tensor<float>(y{})"), summaryFeatures(profile).get("test_func_via_func_with_expr").type(profile.typeContext(builder.getQueryProfileRegistry()))); @@ -353,8 +353,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void importedFieldsAreAvailable() throws Exception { - SchemaBuilder builder = new SchemaBuilder(); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(); + builder.addSchema(joinLines( "search parent {", " document parent {", " field a type tensor(x[5],y[1000]) {", @@ -363,7 +363,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.importString(joinLines( + builder.addSchema(joinLines( "search child {", " document child { ", " field ref type reference<parent> {", @@ -378,14 +378,14 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - builder.build(); + builder.build(true); } @Test public void undeclaredQueryFeaturesAreAccepted() throws Exception { InspectableDeployLogger logger = new InspectableDeployLogger(); - SchemaBuilder builder = new SchemaBuilder(logger); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(logger); + builder.addSchema(joinLines( "search test {", " document test { ", " field anyfield type double {" + @@ -410,8 +410,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void undeclaredQueryFeaturesAreAcceptedWithWarningWhenUsingTensors() throws Exception { InspectableDeployLogger logger = new InspectableDeployLogger(); - SchemaBuilder builder = new SchemaBuilder(logger); - builder.importString(joinLines( + ApplicationBuilder builder = new ApplicationBuilder(logger); + builder.addSchema(joinLines( "search test {", " document test { ", " field anyfield type tensor(d[2]) {", @@ -439,7 +439,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void noWarningWhenUsingTensorsWhenQueryFeaturesAreDeclared() throws Exception { InspectableDeployLogger logger = new InspectableDeployLogger(); - SchemaBuilder builder = new SchemaBuilder(logger); + ApplicationBuilder builder = new ApplicationBuilder(logger); QueryProfileType myType = new QueryProfileType("mytype"); myType.addField(new FieldDescription("rank.feature.query(foo)", new TensorFieldType(TensorType.fromSpec("tensor(d[2])"))), @@ -451,7 +451,7 @@ public class RankingExpressionTypeResolverTestCase { new TensorFieldType(TensorType.fromSpec("tensor(d[2])"))), builder.getQueryProfileRegistry().getTypeRegistry()); builder.getQueryProfileRegistry().getTypeRegistry().register(myType); - builder.importString(joinLines( + builder.addSchema(joinLines( "search test {", " document test { ", " field anyfield type tensor(d[2]) {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java index 09aa09a626b..2a9d64767ba 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java @@ -399,8 +399,10 @@ public class RankingExpressionWithOnnxTestCase { @Override public List<NamedReader> getFiles(Path path, String suffix) { + File[] files = getFileReference(path).listFiles(); + if (files == null) return List.of(); List<NamedReader> readers = new ArrayList<>(); - for (File file : getFileReference(path).listFiles()) { + for (File file : files) { if ( ! file.getName().endsWith(suffix)) continue; try { readers.add(new NamedReader(file.getName(), new FileReader(file))); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java index 93de116883a..ffc073ed434 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java @@ -9,7 +9,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.expressiontransforms.RankProfileTransformContext; import com.yahoo.searchdefinition.expressiontransforms.TokenTransformer; import com.yahoo.searchdefinition.parser.ParseException; @@ -87,9 +87,9 @@ public class RankingExpressionWithTransformerTokensTestCase { " document test {}\n" + " rank-profile my_profile inherits default {}\n" + "}"; - SchemaBuilder schemaBuilder = new SchemaBuilder(application, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); - schemaBuilder.importString(sdContent); - schemaBuilder.build(); + ApplicationBuilder schemaBuilder = new ApplicationBuilder(application, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); + schemaBuilder.addSchema(sdContent); + schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); RankProfile rp = rankProfileRegistry.get(schema, "my_profile"); return new RankProfileTransformContext(rp, queryProfileRegistry, Collections.emptyMap(), null, Collections.emptyMap(), Collections.emptyMap()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java index f4742be6b30..b42f932ef98 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java @@ -11,7 +11,7 @@ import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.AbstractSchemaTestCase; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.RawRankProfile; @@ -31,7 +31,7 @@ import static org.junit.Assert.assertTrue; public class RankingExpressionsTestCase extends AbstractSchemaTestCase { private static Schema createSearch(String dir, ModelContext.Properties deployProperties, RankProfileRegistry rankProfileRegistry) throws IOException, ParseException { - return SchemaBuilder.createFromDirectory(dir, new MockFileRegistry(), new TestableDeployLogger(), deployProperties, rankProfileRegistry).getSchema(); + return ApplicationBuilder.createFromDirectory(dir, new MockFileRegistry(), new TestableDeployLogger(), deployProperties, rankProfileRegistry).getSchema(); } @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java index c9437761e0d..d60cb9040d8 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.document.Field; import com.yahoo.document.ReferenceDataType; import com.yahoo.searchdefinition.DocumentGraphValidator; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Rule; @@ -28,7 +28,7 @@ public class ReferenceFieldTestCase { @Test public void reference_fields_are_parsed_from_search_definition() throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); + ApplicationBuilder builder = new ApplicationBuilder(); String campaignSdContent = "search campaign {\n" + " document campaign {\n" + @@ -46,10 +46,10 @@ public class ReferenceFieldTestCase { " field salesperson_ref type reference<salesperson> { indexing: attribute }\n" + " }\n" + "}"; - builder.importString(campaignSdContent); - builder.importString(salespersonSdContent); - builder.importString(adSdContent); - builder.build(); + builder.addSchema(campaignSdContent); + builder.addSchema(salespersonSdContent); + builder.addSchema(adSdContent); + builder.build(true); Schema schema = builder.getSchema("ad"); assertSearchContainsReferenceField("campaign_ref", "campaign", schema.getDocument()); assertSearchContainsReferenceField("salesperson_ref", "salesperson", schema.getDocument()); @@ -57,7 +57,7 @@ public class ReferenceFieldTestCase { @Test public void cyclic_document_dependencies_are_detected() throws ParseException { - SchemaBuilder builder = new SchemaBuilder(); + ApplicationBuilder builder = new ApplicationBuilder(); String campaignSdContent = "search campaign {\n" + " document campaign {\n" + @@ -70,11 +70,11 @@ public class ReferenceFieldTestCase { " field campaign_ref type reference<campaign> { indexing: attribute }\n" + " }\n" + "}"; - builder.importString(campaignSdContent); - builder.importString(adSdContent); + builder.addSchema(campaignSdContent); + builder.addSchema(adSdContent); exceptionRule.expect(DocumentGraphValidator.DocumentGraphException.class); exceptionRule.expectMessage("Document dependency cycle detected: campaign->ad->campaign."); - builder.build(); + builder.build(true); } private static void assertSearchContainsReferenceField(String expectedFieldname, @@ -87,4 +87,5 @@ public class ReferenceFieldTestCase { ReferenceDataType refField = (ReferenceDataType) dataType; assertEquals(referencedDocType, refField.getTargetType().getName()); } + } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java index 922680e8f1a..d3d79fd7798 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -21,8 +21,8 @@ public class ReservedRankingExpressionFunctionNamesTestCase { public void requireThatFunctionsWithReservedNamesIssueAWarning() throws ParseException { TestDeployLogger deployLogger = new TestDeployLogger(); RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SchemaBuilder builder = new SchemaBuilder(deployLogger, rankProfileRegistry); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(deployLogger, rankProfileRegistry); + builder.addSchema( "search test {\n" + " document test { \n" + " field a type string { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java index 24dc98e4d93..4cfe4c09052 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.processing; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,7 +17,7 @@ public class SchemaMustHaveDocumentTest { @Test public void requireErrorWhenMissingDocument() throws IOException, ParseException { try { - SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_missing_document.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalid_sd_missing_document.sd"); fail("SD without document"); } catch (IllegalArgumentException e) { if (!e.getMessage() diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java index 067a132cc4a..f224dc0688e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.SummaryTransform; import org.junit.Test; @@ -39,7 +39,7 @@ public class SummaryConsistencyTestCase { "", "}" ); - Schema schema = SchemaBuilder.createFromString(sd).getSchema(); + Schema schema = ApplicationBuilder.createFromString(sd).getSchema(); assertEquals(SummaryTransform.ATTRIBUTECOMBINER, schema.getSummaryField("elem_array_unfiltered").getTransform()); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java index eb3e61b9f7a..1eb5e66df93 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -21,7 +21,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatInvalidSourceIsCaught() throws IOException, ParseException { try { - SchemaBuilder.buildFromFile("src/test/examples/invalidsummarysource.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalidsummarysource.sd"); fail("This should throw and never get here"); } catch (IllegalArgumentException e) { assertEquals("For schema 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'nonexistingfield'.", e.getMessage()); @@ -31,7 +31,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatInvalidImplicitSourceIsCaught() throws IOException, ParseException { try { - SchemaBuilder.buildFromFile("src/test/examples/invalidimplicitsummarysource.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalidimplicitsummarysource.sd"); fail("This should throw and never get here"); } catch (IllegalArgumentException e) { assertEquals("For schema 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'cox'.", e.getMessage()); @@ -41,7 +41,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatInvalidSelfReferingSingleSource() throws IOException, ParseException { try { - SchemaBuilder.buildFromFile("src/test/examples/invalidselfreferringsummary.sd"); + ApplicationBuilder.buildFromFile("src/test/examples/invalidselfreferringsummary.sd"); fail("This should throw and never get here"); } catch (IllegalArgumentException e) { assertEquals("For schema 'invalidselfreferringsummary', summary class 'withid', summary field 'w': there is no valid source 'w'.", e.getMessage()); @@ -50,7 +50,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatDocumentIdIsAllowedToPass() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/documentidinsummary.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/documentidinsummary.sd"); BaseDeployLogger deployLogger = new BaseDeployLogger(); RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); new SummaryFieldsMustHaveValidSource(schema, deployLogger, rankProfileRegistry, new QueryProfiles()).process(true, false); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java index 82b288dc66d..9e53bd57d77 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; -import static com.yahoo.searchdefinition.SchemaBuilder.createFromString; +import static com.yahoo.searchdefinition.ApplicationBuilder.createFromString; import static com.yahoo.config.model.test.TestUtil.joinLines; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java index eec2ef4c3a0..c71fd3dd489 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java @@ -14,7 +14,7 @@ import com.yahoo.searchdefinition.LargeRankExpressions; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.RawRankProfile; @@ -140,8 +140,8 @@ public class TensorTransformTestCase extends AbstractSchemaTestCase { private List<Pair<String, String>> buildSearch(String expression) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfileRegistry queryProfiles = setupQueryProfileTypes(); - SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry, queryProfiles); - builder.importString( + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry, queryProfiles); + builder.addSchema( "search test {\n" + " document test { \n" + " field double_field type double { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java index fe9d19310a9..22fd4e45c4a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java @@ -51,7 +51,7 @@ public class ValidateFieldTypesTest { private static Schema createSearch(String documentType) { return new Schema(documentType, - new Application(MockApplicationPackage.createEmpty()), + MockApplicationPackage.createEmpty(), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java index 2a737f4eb69..e56d6ccf343 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -16,7 +16,7 @@ public class WeightedSetSummaryToTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException { - Schema schema = SchemaBuilder.buildFromFile("src/test/examples/weightedset-summaryto.sd"); + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/weightedset-summaryto.sd"); assertNotNull(schema); } diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java index 754979fb391..33d84cf4313 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.documentmodel; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -27,27 +27,27 @@ public class DocumentModelBuilderImportedFieldsTestCase extends AbstractReferenc } private static class TestDocumentModelBuilder { - private final SchemaBuilder builder = new SchemaBuilder(); + private final ApplicationBuilder builder = new ApplicationBuilder(); public TestDocumentModelBuilder addCampaign() throws ParseException { - builder.importString(joinLines("search campaign {", - " document campaign {", - " field cool_field type string { indexing: attribute }", - " field swag_field type long { indexing: attribute }", - " }", - "}")); + builder.addSchema(joinLines("search campaign {", + " document campaign {", + " field cool_field type string { indexing: attribute }", + " field swag_field type long { indexing: attribute }", + " }", + "}")); return this; } public TestDocumentModelBuilder addPerson() throws ParseException { - builder.importString(joinLines("search person {", - " document person {", - " field name type string { indexing: attribute }", - " }", - "}")); + builder.addSchema(joinLines("search person {", + " document person {", + " field name type string { indexing: attribute }", + " }", + "}")); return this; } public DocumentModel build(String adSdContent) throws ParseException { - builder.importString(adSdContent); - builder.build(); + builder.addSchema(adSdContent); + builder.build(true); return builder.getModel(); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java index f9b9bf2610e..00f39a23a8f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.documentmodel; import com.yahoo.document.ReferenceDataType; import com.yahoo.documentmodel.NewDocumentType; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -56,22 +56,22 @@ public class DocumentModelBuilderReferenceTypeTestCase extends AbstractReference } private static class TestDocumentModelBuilder { - private final SchemaBuilder builder = new SchemaBuilder(); + private final ApplicationBuilder builder = new ApplicationBuilder(); public TestDocumentModelBuilder addCampaign() throws ParseException { - builder.importString(joinLines("search campaign {", - " document campaign {}", - "}")); + builder.addSchema(joinLines("search campaign {", + " document campaign {}", + "}")); return this; } public TestDocumentModelBuilder addPerson() throws ParseException { - builder.importString(joinLines("search person {", - " document person {}", - "}")); + builder.addSchema(joinLines("search person {", + " document person {}", + "}")); return this; } public DocumentModel build(String adSdContent) throws ParseException { - builder.importString(adSdContent); - builder.build(); + builder.addSchema(adSdContent); + builder.build(true); return builder.getModel(); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java index 9dfd05b6fdc..dc88590a198 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.documentmodel; import com.yahoo.document.config.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.configmodel.producers.DocumentManager; @@ -35,10 +35,10 @@ public class DocumentModelBuilderTestCase extends AbstractSchemaTestCase { @Test public void testDocumentTypesWithDocumentField() throws IOException, ParseException { - SchemaBuilder search = new SchemaBuilder(); - search.importFile("src/test/configmodel/types/other_doc.sd"); - search.importFile("src/test/configmodel/types/type_with_doc_field.sd"); - search.build(); + ApplicationBuilder search = new ApplicationBuilder(); + search.addSchemaFile("src/test/configmodel/types/other_doc.sd"); + search.addSchemaFile("src/test/configmodel/types/type_with_doc_field.sd"); + search.build(true); DocumentModel model = search.getModel(); DocumenttypesConfig.Builder documenttypesCfg = new DocumentTypes().produce(model, new DocumenttypesConfig.Builder()); @@ -48,15 +48,15 @@ public class DocumentModelBuilderTestCase extends AbstractSchemaTestCase { @Test public void testMultipleInheritanceArray() throws IOException, ParseException { - SchemaBuilder search = new SchemaBuilder(); - search.importFile("src/test/cfg/search/data/travel/schemas/TTData.sd"); - search.importFile("src/test/cfg/search/data/travel/schemas/TTEdge.sd"); - search.importFile("src/test/cfg/search/data/travel/schemas/TTPOI.sd"); - search.build(); + ApplicationBuilder search = new ApplicationBuilder(); + search.addSchemaFile("src/test/cfg/search/data/travel/schemas/TTData.sd"); + search.addSchemaFile("src/test/cfg/search/data/travel/schemas/TTEdge.sd"); + search.addSchemaFile("src/test/cfg/search/data/travel/schemas/TTPOI.sd"); + search.build(true); } private DocumentModel createAndTestModel(String sd) throws IOException, ParseException { - SchemaBuilder search = SchemaBuilder.createFromFile(sd); + ApplicationBuilder search = ApplicationBuilder.createFromFile(sd); DocumentModel model = search.getModel(); assertEquals(2, model.getDocumentManager().getTypes().size()); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ApplicationBuilderTest.java index b50261b7568..3490568770c 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ApplicationBuilderTest.java @@ -31,7 +31,7 @@ import static org.junit.Assert.fail; /** * @author gjoranv */ -public class SchemaBuilderTest extends ContainerModelBuilderTestBase { +public class ApplicationBuilderTest extends ContainerModelBuilderTestBase { private ChainsConfig chainsConfig() { return root.getConfig(ChainsConfig.class, "default/component/com.yahoo.search.handler.SearchHandler"); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java index cea8d724c30..bcb197ed540 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java @@ -444,7 +444,7 @@ public class IndexingAndDocprocRoutingTest extends ContentBaseTest { for (SearchClusterSpec cluster : searchClusterSpecs) { for (SearchDefSpec def : cluster.searchDefs) { - sds.add(ApplicationPackageUtils.generateSearchDefinition(def.typeName, def.field1Name, def.field2Name)); + sds.add(ApplicationPackageUtils.generateSchema(def.typeName, def.field1Name, def.field2Name)); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentSchemaBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentApplicationBuilderTest.java index b8788ece7b6..11aeea5f90d 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentSchemaBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentApplicationBuilderTest.java @@ -15,7 +15,7 @@ import static org.junit.Assert.assertNull; /** * @author Simon Thoresen Hult */ -public class DomContentSchemaBuilderTest { +public class DomContentApplicationBuilderTest { @Test public void requireThatDefaultsAreNull() throws Exception { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java index 6830ce79f9f..e58c29cc4fd 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java @@ -2,11 +2,12 @@ package com.yahoo.vespa.model.search.test; import com.yahoo.component.ComponentId; +import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.container.QrSearchersConfig; import com.yahoo.document.DataType; import com.yahoo.search.config.ClusterConfig; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -40,7 +41,7 @@ public class SchemaClusterTest { public void testSdConfigLogical() { // sd1 SDDocumentType sdt1 = new SDDocumentType("s1"); - Schema schema1 = new Schema("s1"); + Schema schema1 = new Schema("s1", MockApplicationPackage.createEmpty()); SDField f1 = new SDField("f1", DataType.STRING); f1.addAttribute(new Attribute("f1", DataType.STRING)); f1.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f1")))); @@ -49,17 +50,17 @@ public class SchemaClusterTest { // sd2 SDDocumentType sdt2 = new SDDocumentType("s2"); - Schema schema2 = new Schema("s2"); + Schema schema2 = new Schema("s2", MockApplicationPackage.createEmpty()); SDField f2=new SDField("f2", DataType.STRING); f2.addAttribute(new Attribute("f2", DataType.STRING)); f2.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f2")))); sdt2.addField(f2); schema2.addDocument(sdt2); - SchemaBuilder builder = new SchemaBuilder(); - builder.importRawSchema(schema1); - builder.importRawSchema(schema2); - builder.build(); + ApplicationBuilder builder = new ApplicationBuilder(); + builder.add(schema1); + builder.add(schema2); + builder.build(true); } @Test diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java index 1992b01788f..3a5bb3dc1b3 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java @@ -11,10 +11,9 @@ import java.util.List; */ public class ApplicationPackageUtils { - public static String generateSearchDefinition(String name, String field1, String field2) { - return "" + - "search " + name + "{" + - " document " + name + "{" + + public static String generateSchema(String name, String field1, String field2) { + return "schema " + name + " {" + + " document " + name + " {" + " field " + field1 + " type string {\n" + " indexing: index | summary\n" + " summary: dynamic\n" + @@ -51,7 +50,7 @@ public class ApplicationPackageUtils { List<String> sds = new ArrayList<>(); int i = 0; for (String sdName : sdNames) { - sds.add(generateSearchDefinition(sdName, "f" + (i + 1), "f" + (i + 2))); + sds.add(generateSchema(sdName, "f" + (i + 1), "f" + (i + 2))); i = i + 2; } return sds; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java index ca822b7a99d..0acf32d79a7 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java @@ -90,15 +90,15 @@ public class ZooKeeperClient { } private void writeSchemas(ApplicationPackage app) throws IOException { - Collection<NamedReader> sds = app.getSchemas(); - if (sds.isEmpty()) return; + Collection<NamedReader> schemas = app.getSchemas(); + if (schemas.isEmpty()) return; Path zkPath = getZooKeeperAppPath(USERAPP_ZK_SUBPATH).append(SCHEMAS_DIR); curator.create(zkPath); // Ensures that ranking expressions and other files are also written - writeDir(app.getFile(ApplicationPackage.SEARCH_DEFINITIONS_DIR), zkPath, false); - writeDir(app.getFile(ApplicationPackage.SCHEMAS_DIR), zkPath, false); - for (NamedReader sd : sds) { + writeDir(app.getFile(ApplicationPackage.SEARCH_DEFINITIONS_DIR), zkPath, true); + writeDir(app.getFile(ApplicationPackage.SCHEMAS_DIR), zkPath, true); + for (NamedReader sd : schemas) { curator.set(zkPath.append(sd.getName()), Utf8.toBytes(com.yahoo.io.IOUtils.readAll(sd.getReader()))); sd.getReader().close(); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java index aa087f58059..4abad09e1dc 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java @@ -62,8 +62,7 @@ public class OsUpgradeScheduler extends ControllerMaintainer { int hourOfDay = instant.atZone(ZoneOffset.UTC).getHour(); int dayOfWeek = instant.atZone(ZoneOffset.UTC).getDayOfWeek().getValue(); // Upgrade can only be scheduled between 07:00 and 12:59 UTC, Monday-Thursday - return hourOfDay >= 7 && hourOfDay <= 12 && - dayOfWeek < 5; + return hourOfDay >= 7 && hourOfDay <= 12 && dayOfWeek < 5; } private Release releaseIn(CloudName cloud) { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java index 8ff35d26efd..71e6fb8521e 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java @@ -204,7 +204,7 @@ public class NodeFailer extends NodeRepositoryMaintainer { return orchestrator.getApplicationInstanceStatus(node.allocation().get().owner()) == ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN; } catch (ApplicationIdNotFoundException e) { - //Treat it as not suspended and allow to fail the node anyway + // Treat it as not suspended and allow to fail the node anyway return false; } } diff --git a/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java b/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java index 79325075a42..137860ba096 100644 --- a/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java +++ b/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java @@ -18,7 +18,7 @@ import com.yahoo.document.annotation.AnnotationType; import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.documentmodel.VespaDocumentType; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaBuilder; +import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.document.FieldSet; import com.yahoo.searchdefinition.parser.ParseException; import org.apache.maven.plugin.AbstractMojo; @@ -114,7 +114,7 @@ public class DocumentGenMojo extends AbstractMojo { annotationTypes = new HashMap<>(); outputDir.mkdirs(); - SchemaBuilder builder = buildSearches(schemasDir); + ApplicationBuilder builder = buildSearches(schemasDir); boolean annotationsExported=false; for (NewDocumentType docType : builder.getModel().getDocumentManager().getTypes()) { @@ -134,21 +134,21 @@ public class DocumentGenMojo extends AbstractMojo { if (project!=null) project.addCompileSourceRoot(outputDirectory.toString()); } - private SchemaBuilder buildSearches(File sdDir) { + private ApplicationBuilder buildSearches(File sdDir) { File[] sdFiles = sdDir.listFiles((dir, name) -> name.endsWith(".sd")); - SchemaBuilder builder = new SchemaBuilder(true); + ApplicationBuilder builder = new ApplicationBuilder(true); for (File f : sdFiles) { try { long modTime = f.lastModified(); if (modTime > newestModifiedTime) { newestModifiedTime = modTime; } - builder.importFile(f.getAbsolutePath()); + builder.addSchemaFile(f.getAbsolutePath()); } catch (ParseException | IOException e) { throw new IllegalArgumentException(e); } } - builder.build(); + builder.build(true); for (Schema schema : builder.getSchemaList() ) { this.searches.put(schema.getName(), schema); } |