From d3284ac16a88f426128e5da5a9ade9473c3f5a8f Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Sun, 17 Mar 2024 12:50:11 +0100 Subject: Pattern variable --- .../yahoo/vespa/model/container/search/ContainerSearch.java | 6 +++--- .../com/yahoo/vespa/model/content/ContentSearchCluster.java | 12 +++++------- .../vespa/model/builder/xml/dom/ContentBuilderTest.java | 4 +--- .../java/com/yahoo/search/grouping/GroupingValidator.java | 5 ++--- .../main/java/com/yahoo/search/searchers/QueryValidator.java | 5 ++--- 5 files changed, 13 insertions(+), 19 deletions(-) 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 91622e9fe31..de9e9ad7a4b 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 @@ -35,15 +35,15 @@ import static com.yahoo.vespa.model.container.PlatformBundles.SEARCH_AND_DOCPROC * @author gjoranv * @author Tony Vaagenes */ -public class ContainerSearch extends ContainerSubsystem - implements +public class ContainerSearch extends ContainerSubsystem implements IndexInfoConfig.Producer, IlscriptsConfig.Producer, QrSearchersConfig.Producer, QueryProfilesConfig.Producer, SemanticRulesConfig.Producer, PageTemplatesConfig.Producer, - SchemaInfoConfig.Producer { + SchemaInfoConfig.Producer +{ public static final String QUERY_PROFILE_REGISTRY_CLASS = CompiledQueryProfileRegistry.class.getName(); 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 4d6f454f7e0..a92362bf899 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 @@ -89,7 +89,8 @@ public class ContentSearchCluster extends TreeConfigProducer public Builder(Map documentDefinitions, Set globallyDistributedDocuments, - double fractionOfMemoryReserved, ResourceLimits resourceLimits) { + double fractionOfMemoryReserved, ResourceLimits resourceLimits) + { this.documentDefinitions = documentDefinitions; this.globallyDistributedDocuments = globallyDistributedDocuments; this.fractionOfMemoryReserved = fractionOfMemoryReserved; @@ -103,12 +104,9 @@ public class ContentSearchCluster extends TreeConfigProducer Boolean flushOnShutdownElem = clusterElem.childAsBoolean("engine.proton.flush-on-shutdown"); Boolean syncTransactionLog = clusterElem.childAsBoolean("engine.proton.sync-transactionlog"); - var search = new ContentSearchCluster(ancestor, clusterName, - deployState.getProperties().featureFlags(), - documentDefinitions, - globallyDistributedDocuments, - getFlushOnShutdown(flushOnShutdownElem), - syncTransactionLog, + var search = new ContentSearchCluster(ancestor, clusterName, deployState.getProperties().featureFlags(), + documentDefinitions, globallyDistributedDocuments, + getFlushOnShutdown(flushOnShutdownElem), syncTransactionLog, fractionOfMemoryReserved); ModelElement tuning = clusterElem.childByPath("engine.proton.tuning"); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java index d3e69e64fe6..440e7a92ea1 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java @@ -362,9 +362,7 @@ public class ContentBuilderTest extends DomBuilderTest { " " + " " + "", new TestProperties().setEnvironmentVariables(List.of("MY_1_ENV=xyz abc", "MY_2_ENV=2"))); - ContentSearchCluster s; - - s = b.getSearch(); + ContentSearchCluster s = b.getSearch(); assertTrue(s.hasIndexedCluster()); assertNotNull(s.getIndexed()); assertEquals(1, b.getStorageCluster().getChildren().size()); diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java index d61da0ebedf..d4e295fb51f 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java @@ -55,7 +55,7 @@ public class GroupingValidator extends Searcher { var searchCluster = qrsConfig.searchcluster(clusterId); QrSearchersConfig.Searchcluster.Indexingmode.Enum indexingMode = searchCluster.indexingmode(); enabled = (indexingMode != QrSearchersConfig.Searchcluster.Indexingmode.STREAMING); - clusterName = enabled ? searchCluster.name() : null; + clusterName = searchCluster.name(); for (AttributesConfig.Attribute attr : attributesConfig.attribute()) { attributes.put(attr.name(), attr); } @@ -97,8 +97,7 @@ public class GroupingValidator extends Searcher { @Override public void visitExpression(GroupingExpression exp) { - if (exp instanceof AttributeMapLookupValue) { - AttributeMapLookupValue mapLookup = (AttributeMapLookupValue) exp; + if (exp instanceof AttributeMapLookupValue mapLookup) { verifyHasAttribute(mapLookup.getKeyAttribute()); verifyHasAttribute(mapLookup.getValueAttribute()); if (mapLookup.hasKeySourceAttribute()) { diff --git a/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java b/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java index 033e567d53a..1c95a07cdfd 100644 --- a/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java +++ b/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java @@ -11,7 +11,6 @@ import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; import com.yahoo.search.schema.Field; -import com.yahoo.search.schema.FieldInfo; import com.yahoo.search.schema.SchemaInfo; import com.yahoo.search.searchchain.Execution; import com.yahoo.search.searchchain.PhaseNames; @@ -55,7 +54,7 @@ public class QueryValidator extends Searcher { public boolean visit(Item item) { if (item instanceof HasIndexItem indexItem) { var field = schema.fieldInfo(indexItem.getIndexName()); - if (! field.isPresent()) return true; + if (field.isEmpty()) return true; if (field.get().type().kind() == Field.Type.Kind.TENSOR) throw new IllegalArgumentException("Cannot search for terms in '" + indexItem.getIndexName() + "': It is a tensor field"); @@ -76,7 +75,7 @@ public class QueryValidator extends Searcher { if (schema.isStreaming()) return true; // prefix is always supported if (item instanceof PrefixItem prefixItem) { var field = schema.fieldInfo(prefixItem.getIndexName()); - if (! field.isPresent()) return true; + if (field.isEmpty()) return true; if ( ! field.get().isAttribute()) throw new IllegalArgumentException("'" + prefixItem.getIndexName() + "' is not an attribute field: Prefix matching is not supported"); if (field.get().isIndex()) // index overrides attribute -- cgit v1.2.3