diff options
15 files changed, 69 insertions, 273 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java b/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java index a2c220b6cbc..e3d7becd86a 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java @@ -38,7 +38,7 @@ public class VsmSummary extends Derived implements VsmsummaryConfig.Producer { if (doMapField(schema, summaryField)) { SDField sdField = schema.getConcreteField(summaryField.getName()); if (sdField != null && GeoPos.isAnyPos(sdField)) { - summaryMap.put(summaryField, Collections.singletonList(summaryField.getName())); + summaryMap.put(summaryField, List.of(summaryField.getName())); } else { summaryMap.put(summaryField, from); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java deleted file mode 100644 index bd933f1c656..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.application.validation; - -import com.yahoo.document.select.DocumentSelector; -import com.yahoo.vespa.model.application.validation.Validation.Context; -import com.yahoo.vespa.model.search.IndexedSearchCluster; -import com.yahoo.vespa.model.search.SearchCluster; - - -/** - * Validates routing selector for search and content clusters - */ -public class RoutingSelectorValidator implements Validator { - - @Override - public void validate(Context context) { - for (SearchCluster cluster : context.model().getSearchClusters()) { - if (cluster instanceof IndexedSearchCluster) { - IndexedSearchCluster sc = (IndexedSearchCluster) cluster; - String routingSelector = sc.getRoutingSelector(); - if (routingSelector == null) continue; - try { - new DocumentSelector(routingSelector); - } catch (com.yahoo.document.select.parser.ParseException e) { - context.illegal("Failed to parse routing selector for search cluster '" + sc.getClusterName() + "'", e); - } - } - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java index 56b7e6ee0c8..ed0804f7420 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java @@ -7,7 +7,6 @@ import com.yahoo.config.application.api.ValidationOverrides.ValidationException; import com.yahoo.config.model.api.ConfigChangeAction; import com.yahoo.config.model.api.ValidationParameters; import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.config.provision.ClusterSpec; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.application.validation.change.CertificateRemovalChangeValidator; import com.yahoo.vespa.model.application.validation.change.ConfigValueChangeValidator; @@ -28,13 +27,10 @@ import com.yahoo.yolean.Exceptions; import java.util.ArrayList; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.logging.Level; -import java.util.stream.Collectors; /** * Executor of validators. This defines the right order of validator execution. @@ -82,7 +78,6 @@ public class Validation { private static void validateRouting(Execution execution) { new RoutingValidator().validate(execution); - new RoutingSelectorValidator().validate(execution); } private static void validateModel(ValidationParameters validationParameters, Execution execution) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java index 6f9e72117c8..0a8ae69ccf0 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java @@ -5,7 +5,6 @@ import com.yahoo.component.chain.model.ChainSpecification; import com.yahoo.search.searchchain.model.federation.FederationOptions; import com.yahoo.vespa.model.container.component.chain.Chain; -import java.util.Collections; import java.util.List; /** @@ -25,7 +24,7 @@ public class SearchChain extends Chain<Searcher<?>> { //A list of documents types that this search chain provides results for, empty if unknown public List<String> getDocumentTypes() { - return Collections.emptyList(); + return List.of(); } @Override diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java index 0027a9ca45c..fc5b5c25e6d 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 @@ -70,7 +70,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> private final List<SearchNode> nonIndexed = new ArrayList<>(); private final Map<StorageGroup, NodeSpec> groupToSpecMap = new LinkedHashMap<>(); - private Optional<ResourceLimits> resourceLimits = Optional.empty(); + private ResourceLimits resourceLimits; private final ProtonConfig.Indexing.Optimize.Enum feedSequencerType; private final double defaultFeedConcurrency; private final double defaultFeedNiceness; @@ -103,14 +103,13 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> Boolean flushOnShutdownElem = clusterElem.childAsBoolean("engine.proton.flush-on-shutdown"); Boolean syncTransactionLog = clusterElem.childAsBoolean("engine.proton.sync-transactionlog"); - ContentSearchCluster search = new ContentSearchCluster(ancestor, - clusterName, - deployState.getProperties().featureFlags(), - documentDefinitions, - globallyDistributedDocuments, - getFlushOnShutdown(flushOnShutdownElem), - syncTransactionLog, - fractionOfMemoryReserved); + var search = new ContentSearchCluster(ancestor, clusterName, + deployState.getProperties().featureFlags(), + documentDefinitions, + globallyDistributedDocuments, + getFlushOnShutdown(flushOnShutdownElem), + syncTransactionLog, + fractionOfMemoryReserved); ModelElement tuning = clusterElem.childByPath("engine.proton.tuning"); if (tuning != null) { @@ -161,8 +160,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> String clusterName, ContentSearchCluster search) { List<ModelElement> indexedDefs = getIndexedSchemas(clusterElem); if (!indexedDefs.isEmpty()) { - IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0, deployState.featureFlags()); - isc.setRoutingSelector(clusterElem.childAsString("documents.selection")); + IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0, search, deployState.featureFlags()); Double visibilityDelay = clusterElem.childAsDouble("engine.proton.visibility-delay"); if (visibilityDelay != null) { @@ -236,7 +234,6 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> if (queryTimeout != null) { cluster.setQueryTimeout(queryTimeout); } - cluster.defaultDocumentsConfig(); cluster.deriveFromSchemas(deployState); addCluster(cluster); } @@ -295,11 +292,10 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> NodeSpec spec = getNextSearchNodeSpec(parentGroup); SearchNode searchNode; TransactionLogServer tls; - Optional<Tuning> tuning = Optional.ofNullable(this.tuning); if (element == null) { searchNode = SearchNode.create(parent, "" + node.getDistributionKey(), node.getDistributionKey(), spec, clusterName, node, flushOnShutdown, tuning, resourceLimits, deployState.isHosted(), - fractionOfMemoryReserved, this, deployState.featureFlags()); + fractionOfMemoryReserved, deployState.featureFlags()); searchNode.setHostResource(node.getHostResource()); searchNode.initService(deployState); @@ -308,7 +304,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> tls.initService(deployState); } else { searchNode = new SearchNode.Builder(""+node.getDistributionKey(), spec, clusterName, node, flushOnShutdown, - tuning, resourceLimits, fractionOfMemoryReserved, this) + tuning, resourceLimits, fractionOfMemoryReserved) .build(deployState, parent, element.getXml()); tls = new TransactionLogServer.Builder(clusterName, syncTransactionLog).build(deployState, searchNode, element.getXml()); } @@ -337,7 +333,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> public void setTuning(Tuning tuning) { this.tuning = tuning; } private void setResourceLimits(ResourceLimits resourceLimits) { - this.resourceLimits = Optional.of(resourceLimits); + this.resourceLimits = resourceLimits; } public boolean usesHierarchicDistribution() { @@ -345,11 +341,6 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> } public void handleRedundancy(Redundancy redundancy) { - if (hasIndexedCluster()) { - // Important: these must all be the normalized "within a single leaf group" values, - // _not_ the cluster-wide, cross-group values. - indexedCluster.setRedundancy(redundancy.finalRedundancy()); - } this.redundancy = redundancy; } @@ -437,7 +428,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> int numDocumentDbs = builder.documentdb.size(); builder.initialize(new ProtonConfig.Initialize.Builder().threads(numDocumentDbs + 1)); - resourceLimits.ifPresent(limits -> limits.getConfig(builder)); + if (resourceLimits != null) resourceLimits.getConfig(builder); if (tuning != null) { tuning.getConfig(builder); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentSelectionConverter.java b/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentSelectionConverter.java deleted file mode 100644 index 89d2bdaf54f..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentSelectionConverter.java +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright Vespa.ai. 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.document.select.*; -import com.yahoo.document.select.convert.SelectionExpressionConverter; -import com.yahoo.document.select.parser.ParseException; -import java.util.Map; - -/** - * @author Ulf Lilleengen - */ -// TODO: This should be renamed to reflect it is only a validator of expressions -// (in DocumentSelector and SelectionExpressionConverter) -public class DocumentSelectionConverter { - - private final DocumentSelector selector; - private final Map<String, String> queryExpressionMap; - - public DocumentSelectionConverter(String selection) throws ParseException, UnsupportedOperationException, IllegalArgumentException { - this.selector = new DocumentSelector(selection); - NowCheckVisitor nowChecker = new NowCheckVisitor(); - selector.visit(nowChecker); - if (nowChecker.requiresConversion()) { - SelectionExpressionConverter converter = new SelectionExpressionConverter(); - selector.visit(converter); - this.queryExpressionMap = converter.getQueryMap(); - } else { - this.queryExpressionMap = null; - } - } - - /** - * Transforms the selection into a search query. - * - * @return a search query representing the selection - */ - public String getQuery(String documentType) { - if (queryExpressionMap == null) - return null; - if (!queryExpressionMap.containsKey(documentType)) - return null; - return queryExpressionMap.get(documentType); - } - - /** - * Transforms the selection into an inverted search query. - * - * @return a search query representing the selection - */ - public String getInvertedQuery(String documentType) { - String query = getQuery(documentType); - if (query == null) - return null; - return query.replaceAll(">", "<"); - } - -} 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 8824112c118..885cb53a148 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 @@ -20,11 +20,11 @@ import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.vespa.config.search.core.ProtonConfig; import com.yahoo.vespa.configdefinition.IlscriptsConfig; import com.yahoo.vespa.model.content.DispatchTuning; +import com.yahoo.vespa.model.content.Redundancy; import com.yahoo.vespa.model.content.SearchCoverage; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -44,30 +44,21 @@ public class IndexedSearchCluster extends SearchCluster private Tuning tuning; private SearchCoverage searchCoverage; - // This is the document selector string as derived from the subscription tag. - private String routingSelector = null; private final List<DocumentDatabase> documentDbs = new LinkedList<>(); private final MultipleDocumentDatabasesConfigProducer documentDbsConfigProducer; - private int redundancy = 1; + private final Redundancy.Provider redundancyProvider; private final List<SearchNode> searchNodes = new ArrayList<>(); private final DispatchTuning.DispatchPolicy defaultDispatchPolicy; private final double dispatchWarmup; private final String summaryDecodePolicy; - /** - * Returns the document selector that is able to resolve what documents are to be routed to this search cluster. - * This string uses the document selector language as defined in the "document" module. - * - * @return the document selector - */ - public String getRoutingSelector() { - return routingSelector; - } - public IndexedSearchCluster(TreeConfigProducer<AnyConfigProducer> parent, String clusterName, int index, ModelContext.FeatureFlags featureFlags) { + public IndexedSearchCluster(TreeConfigProducer<AnyConfigProducer> parent, String clusterName, int index, + Redundancy.Provider redundancyProvider, ModelContext.FeatureFlags featureFlags) { super(parent, clusterName, index); documentDbsConfigProducer = new MultipleDocumentDatabasesConfigProducer(this, documentDbs); + this.redundancyProvider = redundancyProvider; defaultDispatchPolicy = DispatchTuning.Builder.toDispatchPolicy(featureFlags.queryDispatchPolicy()); dispatchWarmup = featureFlags.queryDispatchWarmup(); summaryDecodePolicy = featureFlags.summaryDecodePolicy(); @@ -102,32 +93,6 @@ public class IndexedSearchCluster extends SearchCluster .configid(sdoc.getConfigId()); } - public void setRoutingSelector(String selector) { - this.routingSelector = selector; - if (this.routingSelector != null) { - try { - new DocumentSelectionConverter(this.routingSelector); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid routing selector: " + e.getMessage()); - } - } - } - /** - * Create default config if not specified by user. - * Accept empty strings as user config - it means that all feeds/documents are accepted. - */ - public void defaultDocumentsConfig() { - if ((routingSelector == null) && !getDocumentNames().isEmpty()) { - Iterator<String> it = getDocumentNames().iterator(); - routingSelector = it.next(); - StringBuilder sb = new StringBuilder(routingSelector); - while (it.hasNext()) { - sb.append(" or ").append(it.next()); - } - routingSelector = sb.toString(); - } - } - @Override public void deriveFromSchemas(DeployState deployState) { for (SchemaInfo spec : schemas().values()) { @@ -188,10 +153,6 @@ public class IndexedSearchCluster extends SearchCluster documentDbsConfigProducer.getConfig(builder); } - public void setRedundancy(int redundancy) { - this.redundancy = redundancy; - } - private static DistributionPolicy.Enum toDistributionPolicy(DispatchTuning.DispatchPolicy tuning) { return switch (tuning) { case ADAPTIVE: yield DistributionPolicy.ADAPTIVE; @@ -227,7 +188,7 @@ public class IndexedSearchCluster extends SearchCluster if (tuning.dispatch.getMaxHitsPerPartition() != null) builder.maxHitsPerNode(tuning.dispatch.getMaxHitsPerPartition()); - builder.redundancy(redundancy); + builder.redundancy(redundancyProvider.redundancy().finalRedundancy()); if (searchCoverage != null) { if (searchCoverage.getMinimum() != null) builder.minSearchCoverage(searchCoverage.getMinimum() * 100.0); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java index c4f1069e0aa..2ab11e31f59 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java @@ -58,14 +58,6 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer /** Returns the document databases contained in this cluster */ public abstract List<DocumentDatabase> getDocumentDbs(); - /** Returns a list of the document type names used in this search cluster */ - public List<String> getDocumentNames() { - return schemas.values() - .stream() - .map(schema -> schema.fullSchema().getDocument().getDocumentName().getName()) - .toList(); - } - public String getClusterName() { return clusterName; } public final String getIndexingModeName() { return getIndexingMode().getName(); } public final boolean isStreaming() { return getIndexingMode() == IndexingMode.STREAMING; } @@ -79,8 +71,6 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer public final void setClusterIndex(int index) { this.index = index; } public final int getClusterIndex() { return index; } - public abstract void defaultDocumentsConfig(); - public abstract void getConfig(AttributesConfig.Builder builder); public abstract void getConfig(RankProfilesConfig.Builder builder); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java index dc4f9273868..61933c10504 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java @@ -21,7 +21,6 @@ import com.yahoo.vespa.model.admin.monitoring.Monitoring; import com.yahoo.vespa.model.application.validation.RestartConfigs; import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; import com.yahoo.vespa.model.content.ContentNode; -import com.yahoo.vespa.model.content.Redundancy; import com.yahoo.vespa.model.content.ResourceLimits; import org.w3c.dom.Element; @@ -64,10 +63,9 @@ public class SearchNode extends AbstractService implements private final String clusterName; private TransactionLogServer tls; private final AbstractService serviceLayerService; - private final Optional<Tuning> tuning; - private final Optional<ResourceLimits> resourceLimits; + private final Tuning tuning; + private final ResourceLimits resourceLimits; private final double fractionOfMemoryReserved; - private final Redundancy.Provider redundancyProvider; public static class Builder extends VespaDomBuilder.DomConfigProducerBuilderBase<SearchNode> { @@ -76,14 +74,13 @@ public class SearchNode extends AbstractService implements private final String clusterName; private final ContentNode contentNode; private final boolean flushOnShutdown; - private final Optional<Tuning> tuning; - private final Optional<ResourceLimits> resourceLimits; + private final Tuning tuning; + private final ResourceLimits resourceLimits; private final double fractionOfMemoryReserved; - private final Redundancy.Provider redundancyProvider; public Builder(String name, NodeSpec nodeSpec, String clusterName, ContentNode node, - boolean flushOnShutdown, Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits, - double fractionOfMemoryReserved, Redundancy.Provider redundancyprovider) { + boolean flushOnShutdown, Tuning tuning, ResourceLimits resourceLimits, + double fractionOfMemoryReserved) { this.name = name; this.nodeSpec = nodeSpec; this.clusterName = clusterName; @@ -92,7 +89,6 @@ public class SearchNode extends AbstractService implements this.tuning = tuning; this.resourceLimits = resourceLimits; this.fractionOfMemoryReserved = fractionOfMemoryReserved; - this.redundancyProvider = redundancyprovider; } @Override @@ -100,18 +96,18 @@ public class SearchNode extends AbstractService implements Element producerSpec) { return SearchNode.create(ancestor, name, contentNode.getDistributionKey(), nodeSpec, clusterName, contentNode, flushOnShutdown, tuning, resourceLimits, deployState.isHosted(), - fractionOfMemoryReserved, redundancyProvider, deployState.featureFlags()); + fractionOfMemoryReserved, deployState.featureFlags()); } } public static SearchNode create(TreeConfigProducer<?> parent, String name, int distributionKey, NodeSpec nodeSpec, String clusterName, AbstractService serviceLayerService, boolean flushOnShutdown, - Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits, - boolean isHostedVespa, double fractionOfMemoryReserved, Redundancy.Provider redundancyProvider, + Tuning tuning, ResourceLimits resourceLimits, + boolean isHostedVespa, double fractionOfMemoryReserved, ModelContext.FeatureFlags featureFlags) { SearchNode node = new SearchNode(parent, name, distributionKey, nodeSpec, clusterName, serviceLayerService, flushOnShutdown, - tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved, redundancyProvider); + tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved); if (featureFlags.loadCodeAsHugePages()) { node.addEnvironmentVariable("VESPA_LOAD_CODE_AS_HUGEPAGES", true); } @@ -123,8 +119,8 @@ public class SearchNode extends AbstractService implements private SearchNode(TreeConfigProducer<?> parent, String name, int distributionKey, NodeSpec nodeSpec, String clusterName, AbstractService serviceLayerService, boolean flushOnShutdown, - Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits, boolean isHostedVespa, - double fractionOfMemoryReserved, Redundancy.Provider redundancyProvider) { + Tuning tuning, ResourceLimits resourceLimits, boolean isHostedVespa, + double fractionOfMemoryReserved) { super(parent, name); this.distributionKey = distributionKey; this.serviceLayerService = serviceLayerService; @@ -141,7 +137,6 @@ public class SearchNode extends AbstractService implements // Properties are set in DomSearchBuilder this.tuning = tuning; this.resourceLimits = resourceLimits; - this.redundancyProvider = redundancyProvider; setPropertiesElastic(clusterName, distributionKey); addEnvironmentVariable("OMP_NUM_THREADS", 1); } @@ -277,13 +272,12 @@ public class SearchNode extends AbstractService implements } Optional<NodeResources> nodeResources = getSpecifiedNodeResources(); if (nodeResources.isPresent()) { - var nodeResourcesTuning = new NodeResourcesTuning(nodeResources.get(), - tuning.map(Tuning::threadsPerSearch).orElse(1), - fractionOfMemoryReserved); + int threadsPerSearch = tuning != null ? tuning.threadsPerSearch() : 1; + var nodeResourcesTuning = new NodeResourcesTuning(nodeResources.get(), threadsPerSearch, fractionOfMemoryReserved); nodeResourcesTuning.getConfig(builder); - tuning.ifPresent(t -> t.getConfig(builder)); - resourceLimits.ifPresent(l -> l.getConfig(builder)); + if (tuning != null) tuning.getConfig(builder); + if (resourceLimits != null) resourceLimits.getConfig(builder); } } 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 7a4dd935acf..f3ae7e2a312 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 @@ -95,9 +95,6 @@ public class StreamingSearchCluster extends SearchCluster implements } @Override - public void defaultDocumentsConfig() { } - - @Override public void getConfig(IndexInfoConfig.Builder builder) { derivedConfig.getIndexInfo().getConfig(builder); } diff --git a/config-model/src/main/javacc/SchemaParser.jj b/config-model/src/main/javacc/SchemaParser.jj index 7d251bd3514..255cc3cde70 100644 --- a/config-model/src/main/javacc/SchemaParser.jj +++ b/config-model/src/main/javacc/SchemaParser.jj @@ -2006,14 +2006,27 @@ void inputs(ParsedRankProfile profile) : { Reference reference; TensorType type; + List<Reference> seenInputs = new ArrayList<>(); } { <INPUTS> <LBRACE> (<NL>)* - ( input(profile) (<NL>)*) * + ( + reference = input(profile) { seenInputs.add(reference); } + (<NL> { seenInputs.add(null); })* + )* <RBRACE> + { + Reference last = null; + for (Reference current : seenInputs) { + if (last != null && current != null) { + deployLogger.logApplicationPackage(Level.WARNING, "Expected newline between inputs " + last + " and " + current); + } + last = current; + } + } } -void input(ParsedRankProfile profile) : +Reference input(ParsedRankProfile profile) : { Reference reference; InputType type = new InputType(TensorType.empty, false); @@ -2021,7 +2034,10 @@ void input(ParsedRankProfile profile) : } { reference = inputName() ( type = valueType(reference))? ( <COLON> (<NL>)* defaultValue = tensorValue(type.tensorType()) )? - { profile.addInput(reference, new RankProfile.Input(reference, type, Optional.ofNullable(defaultValue))); } + { + profile.addInput(reference, new RankProfile.Input(reference, type, Optional.ofNullable(defaultValue))); + return reference; + } } /** Returns the reference "query(name)" for both "query(name)" and "name". */ diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java index 75884c298fb..8f9102801c2 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java @@ -28,42 +28,19 @@ public class MockSearchClusters { @Override public void deriveFromSchemas(DeployState deployState) { } + @Override public List<DocumentDatabase> getDocumentDbs() {return List.of();} + @Override public void getConfig(AttributesConfig.Builder builder) {} + @Override public void getConfig(DocumentdbInfoConfig.Builder builder) {} + @Override public void getConfig(RankProfilesConfig.Builder builder) {} + @Override public void getConfig(IndexInfoConfig.Builder builder) {} + @Override public void getConfig(IlscriptsConfig.Builder builder) {} + @Override public void getConfig(SchemaInfoConfig.Builder builder) {} @Override - public List<DocumentDatabase> getDocumentDbs() { - return List.of(); + protected SearchCluster.IndexingMode getIndexingMode() { + return streaming ? SearchCluster.IndexingMode.STREAMING : SearchCluster.IndexingMode.REALTIME; } - @Override - public void defaultDocumentsConfig() {} - - @Override - public void getConfig(AttributesConfig.Builder builder) { - } - - @Override - public void getConfig(DocumentdbInfoConfig.Builder builder) { - } - - @Override - public void getConfig(RankProfilesConfig.Builder builder) { - } - - @Override - public void getConfig(IndexInfoConfig.Builder builder) { - } - - @Override - public void getConfig(IlscriptsConfig.Builder builder) { - } - - @Override - public void getConfig(SchemaInfoConfig.Builder builder) { - } - - @Override - protected SearchCluster.IndexingMode getIndexingMode() { return streaming ? SearchCluster.IndexingMode.STREAMING : SearchCluster.IndexingMode.REALTIME; } - } public static SearchCluster mockSearchCluster(AbstractConfigProducerRoot root, String clusterName, int clusterIndex, boolean isStreaming) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentSelectionConverterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentSelectionConverterTest.java deleted file mode 100644 index f495de2c6a4..00000000000 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentSelectionConverterTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.search.test; - -import com.yahoo.document.select.parser.ParseException; -import com.yahoo.vespa.model.search.DocumentSelectionConverter; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * Unit tests for RemoveSelection. - * @author Ulf Lilleengen - */ -public class DocumentSelectionConverterTest { - @Test - void testQueryConversion() throws ParseException, IllegalArgumentException, UnsupportedOperationException { - DocumentSelectionConverter converter = new DocumentSelectionConverter("music.expire>now() - 3600 and video.expire > now() - 300"); - assertEquals("expire:>now(3600)", converter.getQuery("music")); - assertEquals("expire:<now(3600)", converter.getInvertedQuery("music")); - assertEquals("expire:>now(300)", converter.getQuery("video")); - assertEquals("expire:<now(300)", converter.getInvertedQuery("video")); - assertNull(converter.getQuery("book")); - assertNull(converter.getInvertedQuery("book")); - } - - @Test - void testSelection() throws ParseException, IllegalArgumentException, UnsupportedOperationException { - DocumentSelectionConverter converter = new DocumentSelectionConverter("music.expire>music.expire.nowdate"); - assertNull(converter.getQuery("music")); - assertNull(converter.getInvertedQuery("music")); - } -} diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java index 55a55075625..bc981c3de7c 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java @@ -10,14 +10,11 @@ import com.yahoo.vespa.config.search.core.ProtonConfig; import com.yahoo.vespa.defaults.Defaults; import com.yahoo.vespa.model.Host; import com.yahoo.vespa.model.HostResource; -import com.yahoo.vespa.model.content.Redundancy; import com.yahoo.vespa.model.search.NodeSpec; import com.yahoo.vespa.model.search.SearchNode; import com.yahoo.vespa.model.search.TransactionLogServer; import org.junit.jupiter.api.Test; -import java.util.Optional; - import static org.junit.jupiter.api.Assertions.*; /** @@ -50,7 +47,7 @@ public class SearchNodeTest { private static SearchNode createSearchNode(MockRoot root, String name, int distributionKey, NodeSpec nodeSpec, boolean flushOnShutDown, boolean isHosted, ModelContext.FeatureFlags featureFlags) { return SearchNode.create(root, name, distributionKey, nodeSpec, "mycluster", null, flushOnShutDown, - Optional.empty(), Optional.empty(), isHosted, 0.0, () -> new Redundancy(1,1,1,1,1), featureFlags); + null, null, isHosted, 0.0, featureFlags); } private static SearchNode createSearchNode(MockRoot root) { diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java index ef1575e2101..778eaeda5f0 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java @@ -193,8 +193,8 @@ abstract class RoutableFactories80 { } private static ByteBuffer serializeDoc(Document doc) { - var buf = new GrowableByteBuffer(); - doc.serialize(buf); + var buf = new GrowableByteBuffer(8 * 1024, 2.0f); + doc.serialize(DocumentSerializerFactory.createHead(buf)); buf.flip(); return buf.getByteBuffer(); } @@ -233,7 +233,7 @@ abstract class RoutableFactories80 { } private static ByteBuffer serializeUpdate(DocumentUpdate update) { - var buf = new GrowableByteBuffer(); + var buf = new GrowableByteBuffer(4 * 1024, 2.0f); update.serialize(DocumentSerializerFactory.createHead(buf)); buf.flip(); return buf.getByteBuffer(); |