aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2022-12-02 23:09:25 +0100
committerGitHub <noreply@github.com>2022-12-02 23:09:25 +0100
commitafcf1bb71cb7b87a03149d197f724cfc7603ef92 (patch)
treefff1df3e68101edc3d3d3b98b5eb51b7758c209c
parent7f870bf3cb8dd0a3d015a448608ba7291a783932 (diff)
parentfcf664e1a6bb9890bd54ff4f8b78497236152bf2 (diff)
Merge pull request #25096 from vespa-engine/revert-25091-revert-25088-balder/immutablelist-2-listv8.94.46
Revert "Revert "Let list handling catch up with Java 17""
-rw-r--r--athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidator.java19
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java5
-rw-r--r--bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java2
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java8
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/RecordWithOverride.java5
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/SwitchStatement.java9
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java9
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/provision/Host.java9
-rw-r--r--config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java7
-rw-r--r--config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java27
-rw-r--r--config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java15
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java36
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java7
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java36
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java18
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java23
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java3
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java3
-rw-r--r--container-core/src/main/java/com/yahoo/component/chain/Chain.java3
-rw-r--r--container-core/src/main/java/com/yahoo/processing/handler/ProcessingResponse.java7
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/IndexFacts.java31
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/Query.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/FederationResult.java11
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java24
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java9
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java16
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java17
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java12
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/model/federation/FederationSearcherModel.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/model/federation/LocalProviderSpec.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java91
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java30
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java5
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java3
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java11
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ServiceConvergence.java3
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Contact.java4
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java4
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Mail.java5
-rw-r--r--standalone-container/src/main/java/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.java13
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java28
51 files changed, 262 insertions, 415 deletions
diff --git a/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidator.java b/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidator.java
index fc21f8271c4..6b7a4835aee 100644
--- a/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidator.java
+++ b/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidator.java
@@ -19,11 +19,11 @@ import com.yahoo.vespa.hosted.provision.NodeRepository;
import java.net.InetAddress;
import java.security.PublicKey;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@@ -119,10 +119,7 @@ public class InstanceValidator {
// Find a list of SAN DNS
List<String> sanDNS = Optional.ofNullable(instanceConfirmation.attributes.get(SAN_DNS_ATTRNAME))
.map(s -> s.split(","))
- .map(Arrays::asList)
- .map(List::stream)
- .orElse(Stream.empty())
- .collect(Collectors.toList());
+ .map(Arrays::asList).stream().flatMap(Collection::stream).toList();
return sanDNS.stream()
.filter(dns -> dns.contains(INSTANCE_ID_DELIMITER))
@@ -152,15 +149,13 @@ public class InstanceValidator {
// Find list of ipaddresses
List<InetAddress> ips = Optional.ofNullable(confirmation.attributes.get(SAN_IPS_ATTRNAME))
.map(s -> s.split(","))
- .map(Arrays::asList)
- .map(List::stream)
- .orElse(Stream.empty())
+ .map(Arrays::asList).stream().flatMap(Collection::stream)
.map(InetAddresses::forString)
- .collect(Collectors.toList());
+ .toList();
List<InetAddress> nodeIpAddresses = node.ipConfig().primary().stream()
.map(InetAddresses::forString)
- .collect(Collectors.toList());
+ .toList();
// Validate that ipaddresses in request are valid for node
@@ -187,7 +182,7 @@ public class InstanceValidator {
Optional<ApplicationInfo> applicationInfo = superModelProvider.getSuperModel().getApplicationInfo(applicationId);
- if (!applicationInfo.isPresent()) {
+ if (applicationInfo.isEmpty()) {
log.info(String.format("Could not find application info for %s, existing applications: %s",
applicationId.serializedForm(),
superModelProvider.getSuperModel().getAllApplicationInfos()));
@@ -207,7 +202,7 @@ public class InstanceValidator {
.filter(serviceInfo -> serviceInfo.getProperty(SERVICE_PROPERTIES_SERVICE_KEY).isPresent())
.findFirst();
- if (!matchingServiceInfo.isPresent()) {
+ if (matchingServiceInfo.isEmpty()) {
log.info(String.format("Application %s has not specified domain/service", applicationId.serializedForm()));
return false;
}
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java
index 9a91d7372da..c3e4ba44fc8 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.athenz.instanceproviderservice;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.Version;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.HostInfo;
@@ -145,7 +144,7 @@ public class InstanceValidatorTest {
nodeList = allocateNode(nodeList, node, applicationId);
when(nodes.list()).thenReturn(NodeList.copyOf(nodeList));
String nodeIp = node.ipConfig().primary().stream().findAny().orElseThrow(() -> new RuntimeException("No ipaddress for mocked node"));
- InstanceConfirmation instanceConfirmation = createRefreshInstanceConfirmation(applicationId, domain, service, ImmutableList.of(nodeIp));
+ InstanceConfirmation instanceConfirmation = createRefreshInstanceConfirmation(applicationId, domain, service, List.of(nodeIp));
assertTrue(instanceValidator.isValidRefresh(instanceConfirmation));
}
@@ -179,7 +178,7 @@ public class InstanceValidatorTest {
List<Node> nodeList = createNodes(10);
when(nodes.list()).thenReturn(NodeList.copyOf(nodeList));
- InstanceConfirmation instanceConfirmation = createRefreshInstanceConfirmation(applicationId, domain, service, ImmutableList.of("::11"));
+ InstanceConfirmation instanceConfirmation = createRefreshInstanceConfirmation(applicationId, domain, service, List.of("::11"));
assertFalse(instanceValidator.isValidRefresh(instanceConfirmation));
diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java
index 2ad77e2433b..e2de90a6463 100644
--- a/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java
+++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.plugin.classanalysis;
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Sets;
import com.yahoo.container.plugin.util.Maps;
@@ -21,7 +20,6 @@ public class PackageTally {
private final Map<String, Optional<ExportPackageAnnotation>> definedPackagesMap;
private final Set<String> referencedPackagesUnfiltered;
- @VisibleForTesting
PackageTally(Map<String, Optional<ExportPackageAnnotation>> definedPackagesMap, Set<String> referencedPackagesUnfiltered) {
this.definedPackagesMap = definedPackagesMap;
this.referencedPackagesUnfiltered = referencedPackagesUnfiltered;
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java
index 8f78363dab5..9a7aade7ffb 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.plugin.classanalysis;
-import com.google.common.collect.ImmutableList;
import com.yahoo.container.plugin.classanalysis.sampleclasses.Base;
import com.yahoo.container.plugin.classanalysis.sampleclasses.ClassAnnotation;
import com.yahoo.container.plugin.classanalysis.sampleclasses.InvisibleAnnotation;
@@ -25,6 +24,7 @@ import java.awt.image.ImagingOpException;
import java.awt.image.Kernel;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.analyzeClass;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.classFile;
@@ -176,7 +176,7 @@ public class AnalyzeClassTest {
@Test
void switch_statements_are_analyzed() {
var referencedClasses = analyzeClass(SwitchStatement.class).getReferencedClasses();
- assertTrue(referencedClasses.contains(name(ImmutableList.class)));
+ assertTrue(referencedClasses.contains(name(List.class)));
assertTrue(referencedClasses.contains(name(IllegalArgumentException.class)));
}
@@ -184,9 +184,9 @@ public class AnalyzeClassTest {
void records_are_analyzed() {
var referencedClasses = analyzeClass(RecordWithOverride.class).getReferencedClasses();
assertTrue(referencedClasses.containsAll(List.of(
- name(java.util.List.class),
+ name(List.class),
name(Byte.class),
- name(ImmutableList.class),
+ name(String.class),
name(IllegalArgumentException.class)
)));
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/RecordWithOverride.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/RecordWithOverride.java
index 299a9930215..67c6430ce06 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/RecordWithOverride.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/RecordWithOverride.java
@@ -1,7 +1,6 @@
package com.yahoo.container.plugin.classanalysis.sampleclasses;
-import com.google.common.collect.ImmutableList;
-
+import java.util.ArrayList;
import java.util.List;
/**
@@ -13,7 +12,7 @@ import java.util.List;
public record RecordWithOverride(List<Byte> list) {
public RecordWithOverride {
- if (list instanceof ImmutableList<Byte> l) {
+ if (list instanceof ArrayList<Byte> l) {
throw new IllegalArgumentException(l.toString());
}
}
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/SwitchStatement.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/SwitchStatement.java
index 5dbe90e2b58..f665d31150e 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/SwitchStatement.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/sampleclasses/SwitchStatement.java
@@ -1,9 +1,8 @@
package com.yahoo.container.plugin.classanalysis.sampleclasses;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
import java.util.Collection;
+import java.util.List;
+import java.util.Set;
/**
* Input for class analysis test verifying Java 14 switch statement.
@@ -15,8 +14,8 @@ public class SwitchStatement {
void switchStatement() throws Exception{
String foo = "";
Collection<?> c = switch (foo) {
- case "list" -> ImmutableList.of();
- case "set" -> ImmutableSet.of();
+ case "list" -> List.of();
+ case "set" -> Set.of();
default -> throw new IllegalArgumentException();
};
}
diff --git a/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java b/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java
index 4ae9834b87f..7fe7c4b9f68 100644
--- a/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java
+++ b/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.admin;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.model.ApplicationConfigProducerRoot;
import com.yahoo.config.model.ConfigModel;
import com.yahoo.config.model.ConfigModelContext;
@@ -65,8 +64,8 @@ public class AdminModel extends ConfigModel {
public static class BuilderV2 extends ConfigModelBuilder<AdminModel> {
public static final List<ConfigModelId> configModelIds =
- ImmutableList.of(ConfigModelId.fromNameAndVersion("admin", "2.0"),
- ConfigModelId.fromNameAndVersion("admin", "1.0"));
+ List.of(ConfigModelId.fromNameAndVersion("admin", "2.0"),
+ ConfigModelId.fromNameAndVersion("admin", "1.0"));
public BuilderV2() {
super(AdminModel.class);
@@ -98,8 +97,8 @@ public class AdminModel extends ConfigModel {
public static class BuilderV4 extends ConfigModelBuilder<AdminModel> {
public static final List<ConfigModelId> configModelIds =
- ImmutableList.of(ConfigModelId.fromNameAndVersion("admin", "3.0"),
- ConfigModelId.fromNameAndVersion("admin", "4.0"));
+ List.of(ConfigModelId.fromNameAndVersion("admin", "3.0"),
+ ConfigModelId.fromNameAndVersion("admin", "4.0"));
public BuilderV4() {
super(AdminModel.class);
diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/Host.java b/config-model/src/main/java/com/yahoo/config/model/provision/Host.java
index ea7a0bc0504..e4bbf55b541 100644
--- a/config-model/src/main/java/com/yahoo/config/model/provision/Host.java
+++ b/config-model/src/main/java/com/yahoo/config/model/provision/Host.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.provision;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.Version;
import com.yahoo.config.provision.Flavor;
@@ -16,12 +15,12 @@ import java.util.Optional;
public class Host {
private final String hostname;
- private final ImmutableList<String> aliases;
+ private final List<String> aliases;
private final Optional<Flavor> flavor;
private final Optional<Version> version;
public Host(String hostname) {
- this(hostname, ImmutableList.of(), Optional.empty());
+ this(hostname, List.of(), Optional.empty());
}
public Host(String hostname, List<String> hostAliases) {
@@ -34,7 +33,7 @@ public class Host {
public Host(String hostname, List<String> hostAliases, Optional<Flavor> flavor, Optional<Version> version) {
this.hostname = hostname;
- this.aliases = ImmutableList.copyOf(hostAliases);
+ this.aliases = List.copyOf(hostAliases);
this.flavor = flavor;
this.version = version;
}
@@ -52,7 +51,7 @@ public class Host {
@Override
public String toString() {
return hostname + (aliases.size() > 0 ? " (aliases: " + aliases + ")" : "" ) +
- (flavor.isPresent() ? " (flavor: " + flavor.get() + ")" : "");
+ (flavor.map(value -> " (flavor: " + value + ")").orElse(""));
}
}
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java
index 14ee60bb9a6..8bdbe574b0e 100644
--- a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java
+++ b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java
@@ -2,7 +2,6 @@
package com.yahoo.schema.derived;
import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
-import com.google.common.collect.ImmutableList;
import com.yahoo.collections.Pair;
import com.yahoo.compress.Compressor;
import com.yahoo.config.model.api.ModelContext;
@@ -86,9 +85,9 @@ public class RawRankProfile implements RankProfilesConfig.Producer {
private List<Pair<String, String>> decompress(Compressor.Compression compression) {
String propertiesString = new String(compressor.decompress(compression), StandardCharsets.UTF_8);
- if (propertiesString.isEmpty()) return ImmutableList.of();
+ if (propertiesString.isEmpty()) return List.of();
- ImmutableList.Builder<Pair<String, String>> properties = new ImmutableList.Builder<>();
+ List<Pair<String, String>> properties = new ArrayList<>();
for (int pos = 0; pos < propertiesString.length();) {
int keyEndPos = propertiesString.indexOf(keyEndMarker, pos);
String key = propertiesString.substring(pos, keyEndPos);
@@ -98,7 +97,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer {
pos = valueEndPos + valueEndMarker.length();
properties.add(new Pair<>(key, value));
}
- return properties.build();
+ return List.copyOf(properties);
}
public String getName() { return name; }
diff --git a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java
index 132597ee75e..42e99f6aa45 100644
--- a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java
+++ b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.expressiontransforms;
-import com.google.common.collect.ImmutableList;
import com.yahoo.searchlib.rankingexpression.RankingExpression;
import com.yahoo.searchlib.rankingexpression.transform.ConstantDereferencer;
import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer;
@@ -24,19 +23,19 @@ public class ExpressionTransforms {
public ExpressionTransforms() {
transforms =
- ImmutableList.of(new TensorFlowFeatureConverter(),
- new OnnxFeatureConverter(),
- new OnnxModelTransformer(),
- new XgboostFeatureConverter(),
- new LightGBMFeatureConverter(),
- new TokenTransformer(),
- new ConstantDereferencer(),
- new ConstantTensorTransformer(),
- new FunctionInliner(),
- new FunctionShadower(),
- new TensorMaxMinTransformer(),
- new Simplifier(),
- new BooleanExpressionTransformer());
+ List.of(new TensorFlowFeatureConverter(),
+ new OnnxFeatureConverter(),
+ new OnnxModelTransformer(),
+ new XgboostFeatureConverter(),
+ new LightGBMFeatureConverter(),
+ new TokenTransformer(),
+ new ConstantDereferencer(),
+ new ConstantTensorTransformer(),
+ new FunctionInliner(),
+ new FunctionShadower(),
+ new TensorMaxMinTransformer(),
+ new Simplifier(),
+ new BooleanExpressionTransformer());
}
public RankingExpression transform(RankingExpression expression, RankProfileTransformContext context) {
diff --git a/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java b/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java
index 1ec4d5b58f2..e1054c365b0 100644
--- a/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java
+++ b/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.processing;
-import com.google.common.collect.ImmutableSet;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.schema.RankProfile;
import com.yahoo.schema.RankProfileRegistry;
@@ -9,8 +8,10 @@ import com.yahoo.schema.Schema;
import com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParserConstants;
import com.yahoo.vespa.model.container.search.QueryProfiles;
+import java.util.Arrays;
import java.util.Set;
import java.util.logging.Level;
+import java.util.stream.Collectors;
/**
* Issues a warning if some function has a reserved name. This is not necessarily
@@ -20,7 +21,7 @@ import java.util.logging.Level;
*/
public class ReservedFunctionNames extends Processor {
- private static Set<String> reservedNames = getReservedNames();
+ private static final Set<String> reservedNames = getReservedNames();
public ReservedFunctionNames(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) {
super(schema, deployLogger, rankProfileRegistry, queryProfiles);
@@ -44,13 +45,9 @@ public class ReservedFunctionNames extends Processor {
}
}
- private static ImmutableSet<String> getReservedNames() {
- ImmutableSet.Builder<String> names = ImmutableSet.builder();
- for (String token : RankingExpressionParserConstants.tokenImage) {
- String tokenWithoutQuotes = token.substring(1, token.length()-1);
- names.add(tokenWithoutQuotes);
- }
- return names.build();
+ private static Set<String> getReservedNames() {
+ return Arrays.stream(RankingExpressionParserConstants.tokenImage)
+ .map(token -> token.substring(1, token.length()-1)).collect(Collectors.toUnmodifiableSet());
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java
index 2348970ed1a..6f4535bf4a1 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java
@@ -2,14 +2,11 @@
package com.yahoo.vespa.model.admin.monitoring;
-
-import com.google.common.collect.ImmutableSet;
-
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import static com.yahoo.vespa.model.admin.monitoring.DefaultVespaMetrics.defaultVespaMetricSet;
-import static java.util.Collections.singleton;
/**
* Metrics for the 'default' consumer, which is used by default for the generic metrics api and
@@ -26,20 +23,19 @@ public class DefaultMetrics {
private static MetricSet createMetricSet() {
return new MetricSet(defaultMetricSetId,
getAllMetrics(),
- singleton(defaultVespaMetricSet));
+ Set.of(defaultVespaMetricSet));
}
private static Set<Metric> getAllMetrics() {
- return ImmutableSet.<Metric>builder()
- .addAll(getContentMetrics())
- .addAll(getContainerMetrics())
- .addAll(getSearchChainMetrics())
- .build();
- }
-
- private static Set<Metric> getContainerMetrics() {
Set<Metric> metrics = new LinkedHashSet<>();
+ addContentMetrics(metrics);
+ addContainerMetrics(metrics);
+ addSearchChainMetrics(metrics);
+ return Collections.unmodifiableSet(metrics);
+ }
+
+ private static void addContainerMetrics(Set<Metric> metrics) {
metrics.add(new Metric("http.status.1xx.rate"));
metrics.add(new Metric("http.status.2xx.rate"));
metrics.add(new Metric("http.status.3xx.rate"));
@@ -47,13 +43,9 @@ public class DefaultMetrics {
metrics.add(new Metric("http.status.5xx.rate"));
metrics.add(new Metric("jdisc.gc.ms.average"));
metrics.add(new Metric("mem.heap.free.average"));
-
- return metrics;
}
- private static Set<Metric> getSearchChainMetrics() {
- Set<Metric> metrics = new LinkedHashSet<>();
-
+ private static void addSearchChainMetrics(Set<Metric> metrics) {
metrics.add(new Metric("queries.rate"));
metrics.add(new Metric("query_latency.sum"));
metrics.add(new Metric("query_latency.count"));
@@ -72,13 +64,9 @@ public class DefaultMetrics {
metrics.add(new Metric("degraded_queries.rate"));
metrics.add(new Metric("failed_queries.rate"));
metrics.add(new Metric("serverActiveThreads.average"));
-
- return metrics;
}
- private static Set<Metric> getContentMetrics() {
- Set<Metric> metrics = new LinkedHashSet<>();
-
+ private static void addContentMetrics(Set<Metric> metrics) {
metrics.add(new Metric("content.proton.search_protocol.docsum.requested_documents.rate"));
metrics.add(new Metric("content.proton.search_protocol.docsum.latency.sum"));
metrics.add(new Metric("content.proton.search_protocol.docsum.latency.count"));
@@ -114,8 +102,6 @@ public class DefaultMetrics {
metrics.add(new Metric("content.proton.documentdb.matching.rank_profile.rerank_time.average")); // TODO: Remove with Vespa 9
metrics.add(new Metric("content.proton.transactionlog.disk_usage.last"));
-
- return metrics;
}
private DefaultMetrics() { }
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java
index 41204ce6e9a..fb67100b435 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.model.admin.monitoring;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
@@ -24,7 +23,7 @@ public class MetricSet {
private final Set<MetricSet> children;
public MetricSet(String id, Collection<Metric> metrics) {
- this(id, metrics, Collections.emptySet());
+ this(id, metrics, Set.of());
}
public MetricSet(String id, Collection<Metric> metrics, Collection<MetricSet> children) {
@@ -57,9 +56,7 @@ public class MetricSet {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof MetricSet)) return false;
-
- MetricSet that = (MetricSet) o;
+ if (!(o instanceof MetricSet that)) return false;
return Objects.equals(id, that.id);
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java
index 4b905f35eab..2f9c97f0488 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java
@@ -22,10 +22,6 @@ public class NetworkMetrics {
new Metric("net.out.dropped")
);
- Set<Metric> networkMetrics = ImmutableSet.<Metric>builder()
- .addAll(dockerNetworkMetrics)
- .build();
-
- return new MetricSet("network", networkMetrics);
+ return new MetricSet("network", dockerNetworkMetrics);
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java b/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java
index 076fe7c0c53..8ddf08a593e 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.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.model.container;
-import com.google.common.collect.ImmutableList;
+
import java.util.ArrayList;
import java.util.List;
@@ -17,7 +17,7 @@ public class SecretStore {
}
public List<Group> getGroups() {
- return ImmutableList.copyOf(groups);
+ return List.copyOf(groups);
}
public static class Group {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java
index 4afde25cafd..1232e32a633 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java
@@ -8,7 +8,6 @@ import ai.vespa.rankingexpression.importer.onnx.OnnxImporter;
import ai.vespa.rankingexpression.importer.tensorflow.TensorFlowImporter;
import ai.vespa.rankingexpression.importer.vespa.VespaImporter;
import ai.vespa.rankingexpression.importer.xgboost.XGBoostImporter;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.FileReference;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.FileRegistry;
@@ -34,6 +33,7 @@ import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -49,7 +49,7 @@ import java.util.Map;
*/
public class ModelsEvaluatorTester {
- private static final ImmutableList<MlModelImporter> importers = ImmutableList.of(new TensorFlowImporter(),
+ private static final List<MlModelImporter> importers = List.of(new TensorFlowImporter(),
new OnnxImporter(),
new LightGBMImporter(),
new XGBoostImporter(),
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
index 13ab012dedb..a78750ded02 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.xml;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.component.Version;
@@ -154,7 +153,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
private final boolean httpServerEnabled;
protected DeployLogger log;
- public static final List<ConfigModelId> configModelIds = ImmutableList.of(ConfigModelId.fromName(CONTAINER_TAG));
+ public static final List<ConfigModelId> configModelIds = List.of(ConfigModelId.fromName(CONTAINER_TAG));
private static final String xmlRendererId = RendererRegistry.xmlRendererId.getName();
private static final String jsonRendererId = RendererRegistry.jsonRendererId.getName();
@@ -217,7 +216,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
addStatusHandlers(cluster, context.getDeployState().isHosted());
addUserHandlers(deployState, cluster, spec, context);
- addClients(deployState, spec, cluster, context);
+ addClients(deployState, spec, cluster);
addHttp(deployState, spec, cluster, context);
addAccessLogs(deployState, cluster, spec);
@@ -380,7 +379,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
// Only consider global endpoints.
.filter(endpoint -> endpoint.scope() == ApplicationClusterEndpoint.Scope.global)
.flatMap(endpoint -> endpoint.names().stream())
- .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
+ .collect(Collectors.toCollection(LinkedHashSet::new));
// Build the comma delimited list of endpoints this container should be known as.
// Confusingly called 'rotations' for legacy reasons.
@@ -491,7 +490,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
}
- protected void addClients(DeployState deployState, Element spec, ApplicationContainerCluster cluster, ConfigModelContext context) {
+ protected void addClients(DeployState deployState, Element spec, ApplicationContainerCluster cluster) {
if (!deployState.isHosted() || !deployState.zone().system().isPublic() || !deployState.featureFlags().enableDataPlaneFilter()) return;
List<Client> clients;
@@ -773,11 +772,10 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
return new JvmGcOptions(context.getDeployState(), jvmGCOptions).build();
}
- private static String getJvmOptions(ApplicationContainerCluster cluster,
- Element nodesElement,
+ private static String getJvmOptions(Element nodesElement,
DeployState deployState,
boolean legacyOptions) {
- return new JvmOptions(cluster, nodesElement, deployState, legacyOptions).build();
+ return new JvmOptions(nodesElement, deployState, legacyOptions).build();
}
private static String extractAttribute(Element element, String attrName) {
@@ -798,7 +796,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
private void extractJvmFromLegacyNodesTag(List<ApplicationContainer> nodes, ApplicationContainerCluster cluster,
Element nodesElement, ConfigModelContext context) {
- applyNodesTagJvmArgs(nodes, getJvmOptions(cluster, nodesElement, context.getDeployState(), true));
+ applyNodesTagJvmArgs(nodes, getJvmOptions(nodesElement, context.getDeployState(), true));
if (cluster.getJvmGCOptions().isEmpty()) {
String jvmGCOptions = extractAttribute(nodesElement, VespaDomBuilder.JVM_GC_OPTIONS);
@@ -810,7 +808,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
private void extractJvmTag(List<ApplicationContainer> nodes, ApplicationContainerCluster cluster,
Element nodesElement, Element jvmElement, ConfigModelContext context) {
- applyNodesTagJvmArgs(nodes, getJvmOptions(cluster, nodesElement, context.getDeployState(), false));
+ applyNodesTagJvmArgs(nodes, getJvmOptions(nodesElement, context.getDeployState(), false));
applyMemoryPercentage(cluster, jvmElement.getAttribute(VespaDomBuilder.Allocated_MEMORY_ATTRIB_NAME));
String jvmGCOptions = extractAttribute(jvmElement, VespaDomBuilder.GC_OPTIONS);
cluster.setJvmGCOptions(buildJvmGCOptions(context, jvmGCOptions));
@@ -1199,14 +1197,12 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
// debug port will not be available in hosted, don't allow
private static final Pattern invalidInHostedatttern = Pattern.compile("-Xrunjdwp:transport=.*");
- private final ContainerCluster<?> cluster;
private final Element nodesElement;
private final DeployLogger logger;
private final boolean legacyOptions;
private final boolean isHosted;
- public JvmOptions(ContainerCluster<?> cluster, Element nodesElement, DeployState deployState, boolean legacyOptions) {
- this.cluster = cluster;
+ public JvmOptions(Element nodesElement, DeployState deployState, boolean legacyOptions) {
this.nodesElement = nodesElement;
this.logger = deployState.getDeployLogger();
this.legacyOptions = legacyOptions;
@@ -1251,10 +1247,9 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
.collect(Collectors.toList());
if (isHosted)
invalidOptions.addAll(Arrays.stream(optionList)
- .filter(option -> !option.isEmpty())
- .filter(option -> Pattern.matches(invalidInHostedatttern.pattern(), option))
- .sorted()
- .collect(Collectors.toList()));
+ .filter(option -> !option.isEmpty())
+ .filter(option -> Pattern.matches(invalidInHostedatttern.pattern(), option))
+ .sorted().toList());
if (invalidOptions.isEmpty()) return;
@@ -1303,10 +1298,9 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
if (isHosted) {
// CMS GC options cannot be used in hosted, CMS is unsupported in JDK 17
invalidOptions.addAll(Arrays.stream(optionList)
- .filter(option -> !option.isEmpty())
- .filter(option -> Pattern.matches(invalidCMSPattern.pattern(), option) ||
- option.equals("-XX:+UseConcMarkSweepGC"))
- .collect(Collectors.toList()));
+ .filter(option -> !option.isEmpty())
+ .filter(option -> Pattern.matches(invalidCMSPattern.pattern(), option) ||
+ option.equals("-XX:+UseConcMarkSweepGC")).toList());
}
logOrFailInvalidOptions(invalidOptions);
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java b/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java
index 15fe8250b71..58c514bdda8 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.processing;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.application.api.ApplicationPackage;
import ai.vespa.rankingexpression.importer.configmodelview.MlModelImporter;
import com.yahoo.config.model.application.provider.BaseDeployLogger;
@@ -37,10 +36,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
class RankProfileSearchFixture {
- private final ImmutableList<MlModelImporter> importers = ImmutableList.of(new TensorFlowImporter(),
- new OnnxImporter(),
- new LightGBMImporter(),
- new XGBoostImporter());
+ private final List<MlModelImporter> importers = List.of(new TensorFlowImporter(),
+ new OnnxImporter(),
+ new LightGBMImporter(),
+ new XGBoostImporter());
private final RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
private final QueryProfileRegistry queryProfileRegistry;
private final Schema schema;
@@ -51,10 +50,6 @@ class RankProfileSearchFixture {
return rankProfileRegistry;
}
- public QueryProfileRegistry getQueryProfileRegistry() {
- return queryProfileRegistry;
- }
-
RankProfileSearchFixture(String rankProfiles) throws ParseException {
this(MockApplicationPackage.createEmpty(), new QueryProfileRegistry(), rankProfiles);
}
@@ -113,11 +108,6 @@ class RankProfileSearchFixture {
return compiled;
}
- /** Returns the given uncompiled profile */
- public RankProfile rankProfile(String rankProfile) {
- return rankProfileRegistry.get(schema, rankProfile);
- }
-
/** Returns the given compiled profile, or null if not compiled yet or not present at all */
public RankProfile compiledRankProfile(String rankProfile) {
return compiledRankProfiles.get(rankProfile);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java
index 8a15d87b6c5..7eec4450f33 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java
@@ -1,11 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.admin.monitoring;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import org.junit.jupiter.api.Test;
+import java.util.List;
import java.util.Map;
import static java.util.Collections.emptyList;
@@ -19,9 +18,9 @@ public class MetricSetTest {
@Test
void metrics_from_children_are_added() {
- MetricSet child1 = new MetricSet("child1", ImmutableList.of(new Metric("child1_metric")));
- MetricSet child2 = new MetricSet("child2", ImmutableList.of(new Metric("child2_metric")));
- MetricSet parent = new MetricSet("parent", emptyList(), ImmutableList.of(child1, child2));
+ MetricSet child1 = new MetricSet("child1", List.of(new Metric("child1_metric")));
+ MetricSet child2 = new MetricSet("child2", List.of(new Metric("child2_metric")));
+ MetricSet parent = new MetricSet("parent", emptyList(), List.of(child1, child2));
Map<String, Metric> parentMetrics = parent.getMetrics();
assertEquals(2, parentMetrics.size());
@@ -31,8 +30,8 @@ public class MetricSetTest {
@Test
void adding_the_same_child_set_twice_has_no_effect() {
- MetricSet child = new MetricSet("child", ImmutableList.of(new Metric("child_metric")));
- MetricSet parent = new MetricSet("parent", emptyList(), ImmutableList.of(child, child));
+ MetricSet child = new MetricSet("child", List.of(new Metric("child_metric")));
+ MetricSet parent = new MetricSet("parent", emptyList(), List.of(child, child));
Map<String, Metric> parentMetrics = parent.getMetrics();
assertEquals(1, parentMetrics.size());
@@ -44,16 +43,10 @@ public class MetricSetTest {
String METRIC_NAME = "metric1";
String COMMON_DIMENSION_KEY = "commonKey";
- Map<String, String> childDimensions = ImmutableMap.<String, String>builder()
- .put(COMMON_DIMENSION_KEY, "childCommonVal")
- .put("childKey", "childVal")
- .build();
+ Map<String, String> childDimensions = Map.of(COMMON_DIMENSION_KEY, "childCommonVal", "childKey", "childVal");
Metric childMetric = new Metric(METRIC_NAME, "child-output-name", "child-description", childDimensions);
- Map<String, String> parentDimensions = ImmutableMap.<String, String>builder()
- .put(COMMON_DIMENSION_KEY, "parentCommonVal")
- .put("parentKey", "parentVal")
- .build();
+ Map<String, String> parentDimensions = Map.of(COMMON_DIMENSION_KEY, "parentCommonVal","parentKey", "parentVal");
Metric parentMetric = new Metric(METRIC_NAME, "parent-output-name", "parent-description", parentDimensions);
MetricSet child = new MetricSet("set1", Sets.newHashSet(childMetric));
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java
index a7f3d134b57..cb535380b18 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. 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.google.common.collect.ImmutableList;
import com.yahoo.collections.Pair;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.api.ConfigChangeAction;
@@ -77,7 +76,7 @@ public class ValidationTester {
Provisioned provisioned = hostProvisioner.startProvisionedRecording();
ApplicationPackage newApp = new MockApplicationPackage.Builder()
.withServices(services)
- .withSchemas(ImmutableList.of(MUSIC_SCHEMA, BOOK_SCHEMA))
+ .withSchemas(List.of(MUSIC_SCHEMA, BOOK_SCHEMA))
.withValidationOverrides(validationOverrides)
.build();
VespaModelCreatorWithMockPkg newModelCreator = new VespaModelCreatorWithMockPkg(newApp);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java
index ed0cedd4e87..a31d4cd4e20 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.test;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.ConfigModelRegistry;
import com.yahoo.config.model.NullConfigModelRegistry;
@@ -90,7 +89,7 @@ public class VespaModelTester {
"-" + Math.round(resources.memoryGb()) +
"-" + Math.round(resources.diskGb()),
count - i);
- hosts.add(new Host(hostname, ImmutableList.of(), flavor));
+ hosts.add(new Host(hostname, List.of(), flavor));
}
this.hostsByResources.put(resources, hosts);
diff --git a/container-core/src/main/java/com/yahoo/component/chain/Chain.java b/container-core/src/main/java/com/yahoo/component/chain/Chain.java
index e44eba35efe..24c4a0a0e2e 100644
--- a/container-core/src/main/java/com/yahoo/component/chain/Chain.java
+++ b/container-core/src/main/java/com/yahoo/component/chain/Chain.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.component.chain;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.dependencies.ordering.ChainBuilder;
@@ -28,7 +27,7 @@ public class Chain<COMPONENT extends ChainedComponent> {
/** Create a chain directly. This will NOT order the chain by the ordering constraints. */
public Chain(ComponentId id, List<COMPONENT> componentList) {
this.id = id;
- this.componentList = ImmutableList.copyOf(componentList);
+ this.componentList = List.copyOf(componentList);
}
/** Create a chain directly. This will NOT order the chain by the ordering constraints. */
diff --git a/container-core/src/main/java/com/yahoo/processing/handler/ProcessingResponse.java b/container-core/src/main/java/com/yahoo/processing/handler/ProcessingResponse.java
index 28645b4bde0..959caa215be 100644
--- a/container-core/src/main/java/com/yahoo/processing/handler/ProcessingResponse.java
+++ b/container-core/src/main/java/com/yahoo/processing/handler/ProcessingResponse.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.processing.handler;
-import com.google.common.collect.ImmutableList;
import com.yahoo.container.jdisc.AsyncHttpResponse;
import com.yahoo.container.jdisc.VespaHeaders;
import com.yahoo.jdisc.handler.CompletionHandler;
@@ -110,13 +109,13 @@ public class ProcessingResponse extends AsyncHttpResponse {
private List<ErrorMessage> flattenErrors(Response processingResponse) {
Set<ErrorMessage> errors = flattenErrors(null, processingResponse.data());
- if (errors == null) return Collections.emptyList();
- return ImmutableList.copyOf(errors);
+ if (errors == null) return List.of();
+ return List.copyOf(errors);
}
@SuppressWarnings("unchecked")
private Set<ErrorMessage> flattenErrors(Set<ErrorMessage> errors, Data data) {
- if (data.request() == null) return Collections.EMPTY_SET; // Not allowed, but handle anyway
+ if (data.request() == null) return Set.of(); // Not allowed, but handle anyway
errors = addTo(errors, data.request().errors());
if (data instanceof DataList) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
index c9a855c2f34..90194f3ba6a 100644
--- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
+++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
@@ -1,10 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude;
-import com.google.common.collect.ImmutableList;
import com.yahoo.search.Query;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
import static com.yahoo.text.Lowercase.toLowerCase;
@@ -57,7 +63,6 @@ public class IndexFacts {
public IndexFacts() {}
- @SuppressWarnings({"deprecation"})
public IndexFacts(IndexModel indexModel) {
if (indexModel.getSearchDefinitions() != null) {
this.searchDefinitions = indexModel.getSearchDefinitions();
@@ -85,20 +90,16 @@ public class IndexFacts {
}
private static void addEntry(Map<String, List<String>> result, String key, String value) {
- List<String> values = result.get(key);
- if (values == null) {
- values = new ArrayList<>();
- result.put(key, values);
- }
+ List<String> values = result.computeIfAbsent(key, k -> new ArrayList<>());
values.add(value);
}
// Assumes that document names are equal to the search definition that contain them.
public List<String> clustersHavingSearchDefinition(String searchDefinitionName) {
- if (clusterByDocument == null) return Collections.emptyList();
+ if (clusterByDocument == null) return List.of();
List<String> clusters = clusterByDocument.get(searchDefinitionName);
- return clusters != null ? clusters : Collections.<String>emptyList();
+ return clusters != null ? clusters : List.of();
}
private boolean isInitialized() {
@@ -168,9 +169,9 @@ public class IndexFacts {
}
private Collection<Index> getIndexes(String documentType) {
- if ( ! isInitialized()) return Collections.emptyList();
+ if ( ! isInitialized()) return List.of();
SearchDefinition sd = searchDefinitions.get(documentType);
- if (sd == null) return Collections.emptyList();
+ if (sd == null) return List.of();
return sd.indices().values();
}
@@ -231,7 +232,7 @@ public class IndexFacts {
}
private Collection<String> emptyCollectionIfNull(Collection<String> collection) {
- return collection == null ? Collections.<String>emptyList() : collection;
+ return collection == null ? List.of() : collection;
}
/**
@@ -318,7 +319,7 @@ public class IndexFacts {
private final List<String> documentTypes;
private Session(Query query) {
- documentTypes = ImmutableList.copyOf(resolveDocumentTypes(query));
+ documentTypes = List.copyOf(resolveDocumentTypes(query));
}
private Session(Collection<String> sources, Collection<String> restrict) {
@@ -347,7 +348,7 @@ public class IndexFacts {
// currently by the flat structure in IndexFacts.
// That can be fixed without changing this API.
public Index getIndex(String indexName, String documentType) {
- return IndexFacts.this.getIndexFromDocumentTypes(indexName, Collections.singletonList(documentType));
+ return IndexFacts.this.getIndexFromDocumentTypes(indexName, List.of(documentType));
}
/** Returns all the indexes of a given search definition */
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java b/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java
index 59dad29ab5c..ea78b2365c5 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java
@@ -9,7 +9,6 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
-import com.google.common.collect.ImmutableList;
import com.yahoo.compress.IntegerCompressor;
/**
@@ -30,7 +29,7 @@ public class WordAlternativesItem extends TermItem {
this.alternatives = uniqueAlternatives(terms);
}
- private static ImmutableList<Alternative> uniqueAlternatives(Collection<Alternative> terms) {
+ private static List<Alternative> uniqueAlternatives(Collection<Alternative> terms) {
List<Alternative> uniqueTerms = new ArrayList<>(terms.size());
for (Alternative term : terms) {
int i = Collections.binarySearch(uniqueTerms, term, (t0, t1) -> t0.word.compareTo(t1.word));
@@ -43,7 +42,7 @@ public class WordAlternativesItem extends TermItem {
uniqueTerms.add(~i, term);
}
}
- return ImmutableList.copyOf(uniqueTerms);
+ return List.copyOf(uniqueTerms);
}
@Override
@@ -177,8 +176,7 @@ public class WordAlternativesItem extends TermItem {
@Override
public boolean equals(Object o) {
- if ( ! (o instanceof Alternative)) return false;
- var other = (Alternative)o;
+ if ( ! (o instanceof Alternative other)) return false;
if ( ! Objects.equals(this.word, other.word)) return false;
if (this.exactness != other.exactness) return false;
return true;
diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java
index be964081326..cff43e07d70 100644
--- a/container-search/src/main/java/com/yahoo/search/Query.java
+++ b/container-search/src/main/java/com/yahoo/search/Query.java
@@ -2,7 +2,6 @@
package com.yahoo.search;
import ai.vespa.cloud.ZoneInfo;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.language.process.Embedder;
@@ -262,7 +261,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
/** Returns an unmodifiable list of all the native properties under a Query */
public static final List<CompoundName> nativeProperties =
- ImmutableList.copyOf(namesUnder(CompoundName.empty, Query.getArgumentType()));
+ List.copyOf(namesUnder(CompoundName.empty, Query.getArgumentType()));
private static List<CompoundName> namesUnder(CompoundName prefix, QueryProfileType type) {
if (type == null) return Collections.emptyList(); // Names not known statically
diff --git a/container-search/src/main/java/com/yahoo/search/federation/FederationResult.java b/container-search/src/main/java/com/yahoo/search/federation/FederationResult.java
index f6cbb49f7d5..89c45fde6ae 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/FederationResult.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/FederationResult.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.federation;
-import com.google.common.collect.ImmutableList;
import com.yahoo.search.Result;
import com.yahoo.search.searchchain.FutureResult;
@@ -27,9 +26,9 @@ class FederationResult {
* The remaining targets to wait for.
* Other targets are either complete, or should only be included if they are available when we complete
*/
- private List<TargetResult> targetsToWaitFor;
+ private final List<TargetResult> targetsToWaitFor;
- private FederationResult(ImmutableList<TargetResult> targetResults) {
+ private FederationResult(List<TargetResult> targetResults) {
this.targetResults = targetResults;
if (targetResults.stream().anyMatch(TargetResult::isMandatory))
@@ -94,7 +93,7 @@ class FederationResult {
public Optional<Result> getIfAvailable(long timeout) {
if (availableResult.isPresent()) return availableResult;
availableResult = futureResult.getIfAvailable(timeout, TimeUnit.MILLISECONDS);
- availableResult.ifPresent(result -> target.modifyTargetResult(result));
+ availableResult.ifPresent(target::modifyTargetResult);
return availableResult;
}
@@ -121,14 +120,14 @@ class FederationResult {
public static class Builder {
- private final ImmutableList.Builder<TargetResult> results = new ImmutableList.Builder();
+ private final List<TargetResult> results = new ArrayList<>();
public void add(FederationSearcher.Target target, FutureResult futureResult) {
results.add(new TargetResult(target, futureResult));
}
public FederationResult build() {
- return new FederationResult(results.build());
+ return new FederationResult(List.copyOf(results));
}
}
diff --git a/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java
index 21b4d1d538f..80a41ffdf22 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.federation;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.annotation.Inject;
import com.yahoo.collections.Pair;
import com.yahoo.component.ComponentId;
@@ -10,7 +9,6 @@ import com.yahoo.component.chain.Chain;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.component.chain.dependencies.Provides;
import com.yahoo.component.provider.ComponentRegistry;
-import com.yahoo.concurrent.CopyOnWriteHashMap;
import com.yahoo.errorhandling.Results;
import com.yahoo.errorhandling.Results.Builder;
import com.yahoo.prelude.IndexFacts;
@@ -28,7 +26,6 @@ import com.yahoo.search.federation.sourceref.SourceRefResolver;
import com.yahoo.search.federation.sourceref.SourcesTarget;
import com.yahoo.search.federation.sourceref.UnresolvedSearchChainException;
import com.yahoo.search.query.Properties;
-import com.yahoo.search.query.properties.SubProperties;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
@@ -77,11 +74,9 @@ public class FederationSearcher extends ForkingSearcher {
public final static CompoundName PROVIDERNAME = new CompoundName("providerName");
public static final String FEDERATION = "Federation";
public static final String LOG_COUNT_PREFIX = "count_";
- private static final List<CompoundName> queryAndHits = ImmutableList.of(Query.OFFSET, Query.HITS);
private final SearchChainResolver searchChainResolver;
private final SourceRefResolver sourceRefResolver;
- private final CopyOnWriteHashMap<CompoundKey, CompoundName> map = new CopyOnWriteHashMap<>();
private final TargetSelector<?> targetSelector;
private final Clock clock = Clock.systemUTC();
@@ -338,22 +333,6 @@ public class FederationSearcher extends ForkingSearcher {
return commentedSearchChains;
}
- /**
- * Returns the set of properties set for the source or provider given in the query (if any).
- *
- * If the query has not set sourceName or providerName, null will be returned
- */
- public static Properties getSourceProperties(Query query) {
- String sourceName = query.properties().getString(SOURCENAME);
- String providerName = query.properties().getString(PROVIDERNAME);
- if (sourceName == null || providerName == null)
- return null;
- Properties sourceProperties = new SubProperties("source." + sourceName, query.properties());
- Properties providerProperties = new SubProperties("provider." + providerName, query.properties());
- sourceProperties.chain(providerProperties);
- return sourceProperties;
- }
-
@Override
public void fill(Result result, String summaryClass, Execution execution) {
UniqueExecutionsToResults uniqueExecutionsToResults = new UniqueExecutionsToResults();
@@ -662,9 +641,8 @@ public class FederationSearcher extends ForkingSearcher {
@Override
public boolean equals(Object o) {
if (o == this) return true;
- if ( ! ( o instanceof StandardTarget)) return false;
+ if ( ! (o instanceof StandardTarget other)) return false;
- StandardTarget other = (StandardTarget)o;
if ( ! Objects.equals(other.chain.getId(), this.chain.getId())) return false;
if ( ! Objects.equals(other.target, this.target)) return false;
return true;
diff --git a/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java b/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
index 34eeb3ce82c..f432289d2c1 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.federation.sourceref;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
@@ -24,7 +23,7 @@ public class SearchChainInvocationSpec implements Cloneable {
public final ComponentId provider;
public final FederationOptions federationOptions;
- public final ImmutableList<String> documentTypes;
+ public final List<String> documentTypes;
SearchChainInvocationSpec(ComponentId searchChainId,
ComponentId source, ComponentId provider, FederationOptions federationOptions,
@@ -33,7 +32,7 @@ public class SearchChainInvocationSpec implements Cloneable {
this.source = source;
this.provider = provider;
this.federationOptions = federationOptions;
- this.documentTypes = ImmutableList.copyOf(documentTypes);
+ this.documentTypes = List.copyOf(documentTypes);
}
@Override
@@ -44,9 +43,8 @@ public class SearchChainInvocationSpec implements Cloneable {
@Override
public boolean equals(Object o) {
if (o == this) return true;
- if ( ! ( o instanceof SearchChainInvocationSpec)) return false;
+ if ( ! (o instanceof SearchChainInvocationSpec other)) return false;
- SearchChainInvocationSpec other = (SearchChainInvocationSpec)o;
if ( ! Objects.equals(this.searchChainId, other.searchChainId)) return false;
if ( ! Objects.equals(this.source, other.source)) return false;
if ( ! Objects.equals(this.provider, other.provider)) return false;
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
index e3ab49f0e32..b58bd64209b 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.provider.FreezableSimpleComponent;
import com.yahoo.processing.IllegalInputException;
@@ -420,7 +419,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
content.freeze();
- inherited= inherited==null ? ImmutableList.of() : ImmutableList.copyOf(inherited);
+ inherited= inherited==null ? List.of() : List.copyOf(inherited);
super.freeze();
}
@@ -616,8 +615,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
* be added (usually because the new value was added to the existing).
*/
static Object combineValues(Object newValue, Object existingValue) {
- if (newValue instanceof QueryProfile) {
- QueryProfile newProfile = (QueryProfile)newValue;
+ if (newValue instanceof QueryProfile newProfile) {
if ( ! (existingValue instanceof QueryProfile)) {
if ( ! isModifiable(newProfile)) {
// Make the query profile reference overridable
@@ -631,8 +629,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
return combineProfiles(newProfile, (QueryProfile)existingValue);
}
else {
- if (existingValue instanceof QueryProfile) { // we need to set a non-leaf value on a query profile
- QueryProfile existingProfile = (QueryProfile)existingValue;
+ if (existingValue instanceof QueryProfile existingProfile) { // we need to set a non-leaf value on a query profile
if (isModifiable(existingProfile)) {
existingProfile.setValue(newValue);
return null;
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java
index 7fc8bfd40ab..57aa3516dfc 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java
@@ -1,11 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* A variant of a query profile
@@ -40,7 +42,7 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa
public Map<String, Object> values() {
if (values == null) {
if (frozen)
- return Collections.emptyMap();
+ return Map.of();
else
values = new HashMap<>();
}
@@ -54,7 +56,7 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa
public List<QueryProfile> inherited() {
if (inherited == null) {
if (frozen)
- return Collections.emptyList();
+ return List.of();
else
inherited = new ArrayList<>();
}
@@ -140,9 +142,9 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa
public void freeze() {
if (frozen) return;
if (inherited != null)
- inherited = ImmutableList.copyOf(inherited);
+ inherited = List.copyOf(inherited);
if (values != null)
- values = ImmutableMap.copyOf(values);
+ values = Map.copyOf(values);
frozen=true;
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java
index 845c2cfd384..1b0472c5b17 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java
@@ -1,12 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.yahoo.component.provider.Freezable;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* This class represent a set of query profiles virtually - rather
@@ -54,7 +57,7 @@ public class QueryProfileVariants implements Freezable, Cloneable {
* on lookup time to influence the value returned.
*/
public QueryProfileVariants(String[] dimensions, QueryProfile owner) {
- this(Arrays.asList(dimensions), owner);
+ this(List.of(dimensions), owner);
}
/**
@@ -77,13 +80,13 @@ public class QueryProfileVariants implements Freezable, Cloneable {
if (frozen) return;
for (FieldValues fieldValues : fieldValuesByName.values())
fieldValues.freeze();
- fieldValuesByName = ImmutableMap.copyOf(fieldValuesByName);
+ fieldValuesByName = Map.copyOf(fieldValuesByName);
inheritedProfiles.freeze();
Collections.sort(variants);
for (QueryProfileVariant variant : variants)
variant.freeze();
- variants = ImmutableList.copyOf(variants);
+ variants = List.copyOf(variants);
frozen=true;
}
@@ -331,7 +334,7 @@ public class QueryProfileVariants implements Freezable, Cloneable {
if (frozen) return;
sort();
if (resolutionList != null)
- resolutionList = ImmutableList.copyOf(resolutionList);
+ resolutionList = List.copyOf(resolutionList);
frozen = true;
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
index f30a3cc5ae6..8fdbf8b2281 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
@@ -1,11 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile.types;
-import com.google.common.collect.ImmutableList;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.query.profile.QueryProfile;
-import java.util.Arrays;
import java.util.List;
/**
@@ -96,14 +94,14 @@ public class FieldDescription implements Comparable<FieldDescription> {
if (name.isCompound() && ! aliases.isEmpty())
throw new IllegalArgumentException("Aliases are not allowed with compound names");
- this.aliases = ImmutableList.copyOf(aliases);
+ this.aliases = List.copyOf(aliases);
this.mandatory = mandatory;
this.overridable = overridable;
}
private static List<String> toList(String string) {
- if (string == null || string.isEmpty()) return ImmutableList.of();
- return ImmutableList.copyOf(Arrays.asList(string.split(" ")));
+ if (string == null || string.isEmpty()) return List.of();
+ return List.of(string.split(" "));
}
/** Returns the full name of this as a string */
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
index 02a4199d32e..3da2ad53f9a 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
@@ -1,12 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile.types;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.yahoo.component.ComponentId;
import com.yahoo.component.provider.FreezableSimpleComponent;
import com.yahoo.processing.request.CompoundName;
-import com.yahoo.search.query.profile.OverridableQueryProfile;
import com.yahoo.search.query.profile.QueryProfile;
import java.util.ArrayList;
@@ -83,8 +80,7 @@ public class QueryProfileType extends FreezableSimpleComponent {
Map<String, FieldDescription> unfrozenFields = new LinkedHashMap<>();
for (Map.Entry<String, FieldDescription> field : fields.entrySet()) {
FieldDescription unfrozenFieldValue = field.getValue();
- if (field.getValue().getType() instanceof QueryProfileFieldType) {
- QueryProfileFieldType queryProfileFieldType = (QueryProfileFieldType)field.getValue().getType();
+ if (field.getValue().getType() instanceof QueryProfileFieldType queryProfileFieldType) {
if (queryProfileFieldType.getQueryProfileType() != null) {
QueryProfileFieldType unfrozenType =
new QueryProfileFieldType(queryProfileFieldType.getQueryProfileType().unfrozen());
@@ -185,8 +181,8 @@ public class QueryProfileType extends FreezableSimpleComponent {
fields.put(field.getName(), field);
}
}
- fields = ImmutableMap.copyOf(fields);
- inherited = ImmutableList.copyOf(inherited);
+ fields = Collections.unmodifiableMap(fields);
+ inherited = List.copyOf(inherited);
strict = isStrict();
matchAsPath = getMatchAsPath();
super.freeze();
@@ -382,7 +378,7 @@ public class QueryProfileType extends FreezableSimpleComponent {
*/
public Map<String, String> aliases() {
if (isFrozen()) return aliases;
- if (aliases == null) return Collections.emptyMap();
+ if (aliases == null) return Map.of();
return Collections.unmodifiableMap(aliases);
}
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/FederationSearcherModel.java b/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/FederationSearcherModel.java
index 8acac776ae8..f39528b3c0f 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/FederationSearcherModel.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/FederationSearcherModel.java
@@ -3,7 +3,6 @@ package com.yahoo.search.searchchain.model.federation;
import java.util.List;
-import com.google.common.collect.ImmutableList;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.component.ComponentSpecification;
@@ -31,7 +30,7 @@ public class FederationSearcherModel extends ChainedComponentModel {
super(BundleInstantiationSpecification.fromSearchAndDocproc(componentId, federationSearcherComponentSpecification),
dependencies);
this.inheritDefaultSources = inheritDefaultSources;
- this.targets = ImmutableList.copyOf(targets);
+ this.targets = List.copyOf(targets);
}
/** Specifies one or more search chains that can be addressed as a single source. */
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/LocalProviderSpec.java b/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/LocalProviderSpec.java
index c4e5f26a3eb..37175df7c35 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/LocalProviderSpec.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/LocalProviderSpec.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.searchchain.model.federation;
-import com.google.common.collect.ImmutableList;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.component.chain.dependencies.Dependencies;
import com.yahoo.component.chain.model.ChainedComponentModel;
@@ -67,6 +66,6 @@ public class LocalProviderSpec {
Dependencies.emptyDependencies()));
}
- return ImmutableList.copyOf(searcherModels);
+ return List.copyOf(searcherModels);
}
}
diff --git a/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java b/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java
index 32880f9b1a8..2c5c1ad83fe 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java
@@ -2,13 +2,7 @@
package com.yahoo.search.yql;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
import com.yahoo.search.yql.yqlplusParser.Annotate_expressionContext;
import com.yahoo.search.yql.yqlplusParser.AnnotationContext;
import com.yahoo.search.yql.yqlplusParser.ArgumentContext;
@@ -66,21 +60,20 @@ import org.antlr.v4.runtime.tree.RuleNode;
import org.antlr.v4.runtime.tree.TerminalNode;
import java.io.IOException;
-import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Stream;
/**
* Translate the ANTLR grammar into the logical representation.
*/
final class ProgramParser {
- public yqlplusParser prepareParser(String programName, InputStream input) throws IOException {
- return prepareParser(programName, new CaseInsensitiveCharStream(CharStreams.fromStream(input)));
- }
-
public yqlplusParser prepareParser(String programName, String input) throws IOException {
return prepareParser(programName, new CaseInsensitiveCharStream(CharStreams.fromString(input)));
}
@@ -142,13 +135,9 @@ final class ProgramParser {
}
private List<String> readName(Namespaced_nameContext node) {
- List<String> path = Lists.newArrayList();
- for (ParseTree elt:node.children) {
- if (!(getParseTreeIndex(elt) == yqlplusParser.DOT)) {
- path.add(elt.getText());
- }
- }
- return path;
+ return node.children.stream()
+ .filter(elt -> !(getParseTreeIndex(elt) == yqlplusParser.DOT))
+ .map(ParseTree::getText).toList();
}
static class Binding {
@@ -164,7 +153,7 @@ final class ProgramParser {
}
public List<String> toPathWith(List<String> rest) {
- return ImmutableList.copyOf(Iterables.concat(toPath(), rest));
+ return Stream.concat(toPath().stream(), rest.stream()).toList();
}
}
@@ -173,9 +162,9 @@ final class ProgramParser {
final Scope root;
final Scope parent;
- Set<String> cursors = ImmutableSet.of();
- Set<String> variables = ImmutableSet.of();
- Map<String, Binding> bindings = Maps.newHashMap();
+ Set<String> cursors = Set.of();
+ Set<String> variables = Set.of();
+ Map<String, Binding> bindings = new HashMap<>();
final yqlplusParser parser;
final String programName;
@@ -231,7 +220,7 @@ final class ProgramParser {
throw new ProgramCompileException(loc, "Alias '%s' is already used.", name);
}
if (cursors.isEmpty()) {
- cursors = Sets.newHashSet();
+ cursors = new HashSet<>();
}
cursors.add(name);
}
@@ -241,7 +230,7 @@ final class ProgramParser {
throw new ProgramCompileException(loc, "Variable/argument '%s' is already used.", name);
}
if (variables.isEmpty()) {
- variables = Sets.newHashSet();
+ variables = new HashSet<>();
}
variables.add(name);
@@ -311,7 +300,7 @@ final class ProgramParser {
// OrderbyContext orderby()
List<Orderby_fieldContext> orderFieds = ((OrderbyContext) child)
.orderby_fields().orderby_field();
- orderby = Lists.newArrayListWithExpectedSize(orderFieds.size());
+ orderby = new ArrayList<>(orderFieds.size());
for (var field: orderFieds) {
orderby.add(convertSortKey(field, scope));
}
@@ -375,7 +364,7 @@ final class ProgramParser {
}
private OperatorNode<SequenceOperator> readMultiSource(Scope scope, Source_listContext multiSource) {
- List<List<String>> sourceNameList = Lists.newArrayList();
+ List<List<String>> sourceNameList = new ArrayList<>();
List<Namespaced_nameContext> nameSpaces = multiSource.namespaced_name();
for(Namespaced_nameContext node : nameSpaces) {
List<String> name = readName(node);
@@ -389,16 +378,16 @@ final class ProgramParser {
for (Pipeline_stepContext step:nodes) {
if (getParseTreeIndex(step.getChild(0)) == yqlplusParser.RULE_vespa_grouping) {
result = OperatorNode.create(SequenceOperator.PIPE, result, List.of(),
- ImmutableList.of(convertExpr(step.getChild(0), scope)));
+ List.of(convertExpr(step.getChild(0), scope)));
} else {
List<String> name = readName(step.namespaced_name());
- List<OperatorNode<ExpressionOperator>> args = ImmutableList.of();
+ List<OperatorNode<ExpressionOperator>> args = List.of();
// LPAREN (argument[$in_select] (COMMA argument[$in_select])*) RPAREN
if (step.getChildCount() > 1) {
ArgumentsContext arguments = step.arguments();
if (arguments.getChildCount() > 2) {
List<ArgumentContext> argumentContextList = arguments.argument();
- args = Lists.newArrayListWithExpectedSize(argumentContextList.size());
+ args = new ArrayList<>(argumentContextList.size());
for (ArgumentContext argumentContext: argumentContextList) {
args.add(convertExpr(argumentContext.expression(), scope.getRoot()));
@@ -471,11 +460,11 @@ final class ProgramParser {
case yqlplusParser.RULE_call_source -> {
List<String> names = readName(dataSourceNode.getChild(Namespaced_nameContext.class, 0));
alias = assignAlias(names.get(names.size() - 1), aliasContext, scope);
- List<OperatorNode<ExpressionOperator>> arguments = ImmutableList.of();
+ List<OperatorNode<ExpressionOperator>> arguments = List.of();
ArgumentsContext argumentsContext = dataSourceNode.getRuleContext(ArgumentsContext.class, 0);
if (argumentsContext != null) {
List<ArgumentContext> argumentContexts = argumentsContext.argument();
- arguments = Lists.newArrayListWithExpectedSize(argumentContexts.size());
+ arguments = new ArrayList<>(argumentContexts.size());
for (ArgumentContext argumentContext : argumentContexts) {
arguments.add(convertExpr(argumentContext, scope));
}
@@ -514,7 +503,7 @@ final class ProgramParser {
yqlplusParser parser,
String programName) {
Scope scope = new Scope(parser, programName);
- List<OperatorNode<StatementOperator>> stmts = Lists.newArrayList();
+ List<OperatorNode<StatementOperator>> stmts = new ArrayList<>();
int output = 0;
for (ParseTree node : program.children) {
if (!(node instanceof ParserRuleContext ruleContext)) continue;
@@ -624,8 +613,8 @@ final class ProgramParser {
}
case yqlplusParser.RULE_map_expression: {
List<Property_name_and_valueContext> propertyList = ((Map_expressionContext)parseTree).property_name_and_value();
- List<String> names = Lists.newArrayListWithExpectedSize(propertyList.size());
- List<OperatorNode<ExpressionOperator>> exprs = Lists.newArrayListWithCapacity(propertyList.size());
+ List<String> names = new ArrayList<>(propertyList.size());
+ List<OperatorNode<ExpressionOperator>> exprs = new ArrayList<>(propertyList.size());
for (Property_name_and_valueContext child : propertyList) {
// : propertyName ':' expression[$expression::namespace] ->
// ^(PROPERTY propertyName expression)
@@ -636,7 +625,7 @@ final class ProgramParser {
}
case yqlplusParser.RULE_array_literal: {
List<Constant_expressionContext> expressionList = ((Array_literalContext) parseTree).constant_expression();
- List<OperatorNode<ExpressionOperator>> values = Lists.newArrayListWithExpectedSize(expressionList.size());
+ List<OperatorNode<ExpressionOperator>> values = new ArrayList<>(expressionList.size());
for (Constant_expressionContext expr : expressionList) {
values.add(convertExpr(expr, scope));
}
@@ -668,7 +657,7 @@ final class ProgramParser {
}
case yqlplusParser.RULE_call_expression: {
List<ArgumentContext> args = ((ArgumentsContext) firstChild.getChild(1)).argument();
- List<OperatorNode<ExpressionOperator>> arguments = Lists.newArrayListWithExpectedSize(args.size());
+ List<OperatorNode<ExpressionOperator>> arguments = new ArrayList<>(args.size());
for (ArgumentContext argContext : args) {
arguments.add(convertExpr(argContext.expression(),scope));
}
@@ -889,7 +878,7 @@ final class ProgramParser {
if (elements.size() == 1 && scope.getParser().isArrayParameter(firldElement)) {
return convertExpr(firldElement, scope);
} else {
- List<OperatorNode<ExpressionOperator>> values = Lists.newArrayListWithExpectedSize(elements.size());
+ List<OperatorNode<ExpressionOperator>> values = new ArrayList<>(elements.size());
for (Literal_elementContext child : elements) {
values.add(convertExpr(child.getChild(0), scope));
}
@@ -906,10 +895,10 @@ final class ProgramParser {
String text = literal.getChild(0).getText();
switch(parseTreeIndex) {
case yqlplusParser.INT:
- Long as_long = Long.valueOf(text);
- int as_int = as_long.intValue();
+ long as_long = Long.parseLong(text);
+ int as_int = (int)as_long;
if (as_int == as_long) {
- return Integer.valueOf(as_int);
+ return as_int;
} else {
return as_long;
}
@@ -943,11 +932,7 @@ final class ProgramParser {
}
case ARRAY: {
List<OperatorNode<ExpressionOperator>> exprs = node.getArgument(0);
- ImmutableList.Builder<Object> lst = ImmutableList.builder();
- for (OperatorNode<ExpressionOperator> expr : exprs) {
- lst.add(readConstantExpression(expr));
- }
- return lst.build();
+ return exprs.stream().map(expr -> readConstantExpression(expr)).toList();
}
case VARREF: {
return node; // must be dereferenced in YqlParser when we have userQuery
@@ -967,7 +952,7 @@ final class ProgramParser {
}
private OperatorNode<ExpressionOperator> readConjOp(ExpressionOperator op, List<Equality_expressionContext> nodes, Scope scope) {
- List<OperatorNode<ExpressionOperator>> arguments = Lists.newArrayListWithExpectedSize(nodes.size());
+ List<OperatorNode<ExpressionOperator>> arguments = new ArrayList<>(nodes.size());
for (ParseTree child : nodes) {
arguments.add(convertExpr(child, scope));
}
@@ -976,13 +961,13 @@ final class ProgramParser {
private OperatorNode<ExpressionOperator> readConjOrOp(ExpressionOperator op, Logical_OR_expressionContext node, Scope scope) {
List<Logical_AND_expressionContext> andExpressionList = node.logical_AND_expression();
- List<OperatorNode<ExpressionOperator>> arguments = Lists.newArrayListWithExpectedSize(andExpressionList.size());
+ List<OperatorNode<ExpressionOperator>> arguments = new ArrayList<>(andExpressionList.size());
for (Logical_AND_expressionContext child : andExpressionList) {
List<Equality_expressionContext> equalities = child.equality_expression();
if (equalities.size() == 1) {
arguments.add(convertExpr(equalities.get(0), scope));
} else {
- List<OperatorNode<ExpressionOperator>> andArguments = Lists.newArrayListWithExpectedSize(equalities.size());
+ List<OperatorNode<ExpressionOperator>> andArguments = new ArrayList<>(equalities.size());
for (Equality_expressionContext subTreeChild:equalities) {
andArguments.add(convertExpr(subTreeChild, scope));
}
@@ -1015,19 +1000,17 @@ final class ProgramParser {
* @return list of READ_FIELD expressions
*/
private List<OperatorNode<ExpressionOperator>> getReadFieldExpressions(OperatorNode<ExpressionOperator> in) {
- List<OperatorNode<ExpressionOperator>> readFieldList = Lists.newArrayList();
+ List<OperatorNode<ExpressionOperator>> readFieldList = new ArrayList<>();
switch (in.getOperator()) {
- case READ_FIELD:
- readFieldList.add(in);
- break;
- case CALL:
+ case READ_FIELD -> readFieldList.add(in);
+ case CALL -> {
List<OperatorNode<ExpressionOperator>> callArgs = in.getArgument(1);
for (OperatorNode<ExpressionOperator> callArg : callArgs) {
if (callArg.getOperator() == ExpressionOperator.READ_FIELD) {
readFieldList.add(callArg);
}
}
- break;
+ }
}
return readFieldList;
}
diff --git a/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java b/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java
index e7ec28a9b97..92f25d57e8a 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.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.search.yql;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,22 +34,14 @@ class ProjectionBuilder {
}
private String assignName(OperatorNode<ExpressionOperator> expr) {
- String baseName = "expr";
- switch (expr.getOperator()) {
- case PROPREF:
- baseName = (String) expr.getArgument(1);
- break;
- case READ_RECORD:
- baseName = (String) expr.getArgument(0);
- break;
- case READ_FIELD:
- baseName = (String) expr.getArgument(1);
- break;
- case VARREF:
- baseName = (String) expr.getArgument(0);
- break;
+ String baseName = switch (expr.getOperator()) {
+ case PROPREF -> (String) expr.getArgument(1);
+ case READ_RECORD -> (String) expr.getArgument(0);
+ case READ_FIELD -> (String) expr.getArgument(1);
+ case VARREF -> (String) expr.getArgument(0);
+ default -> "expr";
// fall through, leaving baseName alone
- }
+ };
int c = 0;
String candidate = baseName;
while (fields.containsKey(candidate)) {
@@ -57,7 +51,7 @@ class ProjectionBuilder {
}
public OperatorNode<SequenceOperator> make(OperatorNode<SequenceOperator> target) {
- ImmutableList.Builder<OperatorNode<ProjectOperator>> lst = ImmutableList.builder();
+ List<OperatorNode<ProjectOperator>> lst = new ArrayList<>();
for (Map.Entry<String, OperatorNode<ExpressionOperator>> e : fields.entrySet()) {
if (e.getKey().startsWith("*")) {
lst.add(OperatorNode.create(ProjectOperator.MERGE_RECORD, e.getValue().getArgument(0)));
@@ -67,7 +61,7 @@ class ProjectionBuilder {
lst.add(OperatorNode.create(ProjectOperator.FIELD, e.getValue(), e.getKey()));
}
}
- return OperatorNode.create(SequenceOperator.PROJECT, target, lst.build());
+ return OperatorNode.create(SequenceOperator.PROJECT, target, List.copyOf(lst));
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
index e9b1cbabc79..73975ecaa96 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.fastsearch.test;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.chain.Chain;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.container.handler.VipStatus;
@@ -143,7 +142,7 @@ public class FastSearcherTestCase {
@Test
void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
- MockDispatcher dispatcher = MockDispatcher.create(ImmutableList.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
+ MockDispatcher dispatcher = MockDispatcher.create(List.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
FastSearcher fastSearcher = new FastSearcher("container.0",
dispatcher,
@@ -185,7 +184,7 @@ public class FastSearcherTestCase {
searchClusterB.name(clusterName);
b.searchcluster(searchClusterB);
VipStatus vipStatus = new VipStatus(b.build());
- List<Node> nodes_1 = ImmutableList.of(new Node(0, "host0", 0));
+ List<Node> nodes_1 = List.of(new Node(0, "host0", 0));
RpcResourcePool rpcPool_1 = new RpcResourcePool(MockDispatcher.toDispatchConfig(), MockDispatcher.toNodesConfig(nodes_1));
MockDispatcher dispatch_1 = MockDispatcher.create(nodes_1, rpcPool_1, vipStatus);
dispatch_1.clusterMonitor.shutdown();
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
index 16e27303fa8..5f9d0a53f06 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.querytransform.test;
-import com.google.common.collect.ImmutableList;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.IndexModel;
@@ -12,7 +11,10 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.test.QueryTestCase;
import org.junit.jupiter.api.Test;
-import java.util.*;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -83,9 +85,9 @@ public class LiteralBoostSearcherTestCase {
private IndexFacts createIndexFacts() {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
- clusters.put("cluster2", Arrays.asList("type4", "type5"));
- Collection<SearchDefinition> searchDefs = ImmutableList.of(
+ clusters.put("cluster1", List.of("type1", "type2", "type3"));
+ clusters.put("cluster2", List.of("type4", "type5"));
+ Collection<SearchDefinition> searchDefs = List.of(
createSearchDefinitionWithFields("type1", true),
createSearchDefinitionWithFields("type2", false),
new SearchDefinition("type3"),
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
index 239f4500297..9eba23e3ab6 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
@@ -4,7 +4,6 @@ package com.yahoo.prelude.querytransform.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.google.common.collect.ImmutableList;
import com.yahoo.language.Linguistics;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.Index;
@@ -23,8 +22,8 @@ import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
@@ -73,12 +72,7 @@ public class NormalizingSearcherTestCase {
}
private String enc(String s) {
- try {
- return URLEncoder.encode(s, "utf-8");
- }
- catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
+ return URLEncoder.encode(s, StandardCharsets.UTF_8);
}
@Test
@@ -129,9 +123,9 @@ public class NormalizingSearcherTestCase {
private IndexFacts createIndexFacts() {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
- clusters.put("cluster2", Arrays.asList("type4", "type5"));
- Collection<SearchDefinition> searchDefs = ImmutableList.of(
+ clusters.put("cluster1", List.of("type1", "type2", "type3"));
+ clusters.put("cluster2", List.of("type4", "type5"));
+ Collection<SearchDefinition> searchDefs = List.of(
createSearchDefinitionWithFields("type1", true),
createSearchDefinitionWithFields("type2", false),
new SearchDefinition("type3"),
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
index d374bfdeb7b..e064f8f2ba0 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
@@ -3,7 +3,6 @@ package com.yahoo.prelude.searcher.test;
import static org.junit.jupiter.api.Assertions.*;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.Chain;
import com.yahoo.container.QrSearchersConfig;
@@ -84,7 +83,7 @@ public class JuniperSearcherTestCase {
private Execution createExecution(Chain<Searcher> chain) {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- Collection<SearchDefinition> searchDefs = ImmutableList.of(createSearchDefinitionOne(), createSearchDefinitionTwo());
+ Collection<SearchDefinition> searchDefs = List.of(createSearchDefinitionOne(), createSearchDefinitionTwo());
IndexModel indexModel = new IndexModel(clusters, searchDefs);
return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel)));
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
index 4b24ba3671e..e6c5a18c9da 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.test;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.language.process.StemMode;
import com.yahoo.prelude.Index;
@@ -13,11 +12,7 @@ import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.search.searchchain.Execution;
import org.junit.jupiter.api.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,7 +23,6 @@ import static org.junit.jupiter.api.Assertions.*;
*
* @author Steinar Knutsen
*/
-@SuppressWarnings({"rawtypes", "unchecked"})
public class IndexFactsTestCase {
private static final String INDEXFACTS_TESTING = "file:src/test/java/com/yahoo/prelude/test/indexfactstesting.cfg";
@@ -45,14 +39,8 @@ public class IndexFactsTestCase {
}
private Map<String, List<String>> createClusters() {
- List<String> clusterOne = new ArrayList<>();
- List<String> clusterTwo = new ArrayList<>();
- clusterOne.addAll(Arrays.asList("one", "two"));
- clusterTwo.addAll(Arrays.asList("one", "three"));
- Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("clusterOne", clusterOne);
- clusters.put("clusterTwo", clusterTwo);
- return clusters;
+ return Map.of("clusterOne", List.of("one", "two"),
+ "clusterTwo", List.of("one", "three"));
}
@Test
@@ -86,7 +74,7 @@ public class IndexFactsTestCase {
sd2.addIndex(a);
assertEquals(sd2.getDefaultPosition(), "a");
- IndexFacts indexFacts = createIndexFacts(ImmutableList.of(sd, sd2));
+ IndexFacts indexFacts = createIndexFacts(List.of(sd, sd2));
assertEquals(indexFacts.getDefaultPosition(null), "a");
assertEquals(indexFacts.getDefaultPosition("sd"), "c");
}
@@ -142,8 +130,6 @@ public class IndexFactsTestCase {
assertExactIsWorking("test");
assertExactIsWorking("artist_name_ft_norm1");
- List search = new ArrayList();
- search.add("three");
Query query = new Query();
query.getModel().getSources().add("three");
IndexFacts.Session threeSession = createIndexFacts().newSession(query);
@@ -194,7 +180,7 @@ public class IndexFactsTestCase {
query.getModel().getSources().add("one");
query.getModel().getRestrict().add("two");
- IndexFacts.Session indexFacts = createIndexFacts().newSession(Collections.singleton("clusterOne"), Collections.emptyList());
+ IndexFacts.Session indexFacts = createIndexFacts().newSession(List.of("clusterOne"), List.of());
assertTrue(indexFacts.isIndex("a"));
assertFalse(indexFacts.isIndex("b"));
assertTrue(indexFacts.isIndex("d"));
@@ -282,7 +268,7 @@ public class IndexFactsTestCase {
b.indexinfo(b3);
IndexInfoConfig config = new IndexInfoConfig(b);
- IndexFacts indexFacts = new IndexFacts(new IndexModel(config, Collections.emptyMap()));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(config, Map.of()));
Query query1 = new Query("?query=url:https://foo.bar");
Query query2 = new Query("?query=url:https://foo.bar&restrict=hasUri");
assertEquals(0, query1.getModel().getRestrict().size());
@@ -308,7 +294,7 @@ public class IndexFactsTestCase {
// Alias to field1 conflics with field1 in the "union" search definition.
// Should not produce an exception (but a log message):
- new IndexFacts(new IndexModel(Collections.emptyMap(), ImmutableList.of(first, second)));
+ new IndexFacts(new IndexModel(Map.of(), List.of(first, second)));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
index cb0d4ab923f..ea29e0a15ff 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.federation;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.IndexFacts;
@@ -14,7 +13,6 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
import org.junit.jupiter.api.Test;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,10 +36,10 @@ public class DuplicateSourceTestCase {
SearchChainRegistry searchChains = new SearchChainRegistry();
searchChains.register(new Chain<>("chain1", mockBackendSearcher));
Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("chain1", ImmutableList.of("doc1", "doc2"));
- IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, Collections.emptyList()));
+ clusters.put("chain1", List.of("doc1", "doc2"));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, List.of()));
SearchChainResolver resolver = new SearchChainResolver.Builder()
- .addSearchChain(new ComponentId("chain1"), ImmutableList.of("doc1", "doc2"))
+ .addSearchChain(new ComponentId("chain1"), List.of("doc1", "doc2"))
.build();
FederationSearcher searcher = new FederationSearcher(new ComponentId("test"), resolver);
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
index 8dccf7d0f38..49449153d1f 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
@@ -1,13 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.querytransform.test;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.chain.Chain;
import com.yahoo.language.Language;
import com.yahoo.language.simple.SimpleLinguistics;
@@ -92,11 +89,11 @@ public class NGramSearcherTestCase {
song.addIndex(songDefault);
Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("musicOnly", Collections.singletonList(music.getName()));
- clusters.put("songOnly", Collections.singletonList(song.getName()));
- clusters.put("musicAndSong", Arrays.asList(music.getName(), song.getName()));
+ clusters.put("musicOnly", List.of(music.getName()));
+ clusters.put("songOnly", List.of(song.getName()));
+ clusters.put("musicAndSong", List.of(music.getName(), song.getName()));
- IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, ImmutableList.of(music, song)));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, List.of(music, song)));
return new Execution(createSearcher(), Execution.Context.createContextStub(indexFacts));
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ServiceConvergence.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ServiceConvergence.java
index f0ed73c2dc9..f0f0078be5a 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ServiceConvergence.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ServiceConvergence.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.configserver;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.zone.ZoneId;
@@ -28,7 +27,7 @@ public class ServiceConvergence {
this.zone = zone;
this.converged = converged;
this.wantedGeneration = wantedGeneration;
- this.services = ImmutableList.copyOf(services);
+ this.services = List.copyOf(services);
}
public ApplicationId application() { return application; }
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Contact.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Contact.java
index a1f27f85500..7e566e07c7f 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Contact.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Contact.java
@@ -1,8 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.organization;
-import com.google.common.collect.ImmutableList;
-
import java.net.URI;
import java.util.List;
import java.util.Objects;
@@ -26,7 +24,7 @@ public class Contact {
this.propertyUrl = Objects.requireNonNull(propertyUrl, "propertyUrl must be non-null");
this.url = Objects.requireNonNull(url, "url must be non-null");
this.issueTrackerUrl = Objects.requireNonNull(issueTrackerUrl, "issueTrackerUrl must be non-null");
- this.persons = ImmutableList.copyOf(Objects.requireNonNull(persons, "persons must be non-null"));
+ this.persons = List.copyOf(Objects.requireNonNull(persons, "persons must be non-null"));
this.queue = queue;
this.component = component;
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java
index 55f65d71165..7db85da1dbb 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java
@@ -1,8 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.organization;
-import com.google.common.collect.ImmutableList;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -30,7 +28,7 @@ public class Issue {
this.summary = summary;
this.description = description;
- this.labels = ImmutableList.copyOf(labels);
+ this.labels = List.copyOf(labels);
this.assignee = assignee;
this.type = type;
this.queue = queue;
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Mail.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Mail.java
index 36b6e251fbc..e84578790ab 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Mail.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Mail.java
@@ -1,9 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.organization;
-import com.google.common.collect.ImmutableList;
+import com.yahoo.prelude.IndexFacts;
import java.util.Collection;
+import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -31,7 +32,7 @@ public class Mail {
if (recipients.isEmpty())
throw new IllegalArgumentException("Empty recipient list is not allowed.");
recipients.forEach(Objects::requireNonNull);
- this.recipients = ImmutableList.copyOf(recipients);
+ this.recipients = List.copyOf(recipients);
this.subject = Objects.requireNonNull(subject);
this.message = Objects.requireNonNull(message);
this.htmlMessage = Objects.requireNonNull(htmlMessage);
diff --git a/standalone-container/src/main/java/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.java b/standalone-container/src/main/java/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.java
index 1526bc3dc5d..48f1efc7615 100644
--- a/standalone-container/src/main/java/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.java
+++ b/standalone-container/src/main/java/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.container.impl;
-import com.google.common.collect.Lists;
import com.yahoo.container.standalone.StandaloneContainerApplication;
import com.yahoo.jdisc.application.OsgiFramework;
import com.yahoo.jdisc.application.OsgiHeader;
@@ -51,15 +50,15 @@ import java.util.jar.JarFile;
*/
public final class ClassLoaderOsgiFramework implements OsgiFramework {
- private BundleContextImpl bundleContextImpl = new BundleContextImpl();
- private SystemBundleImpl systemBundleImpl = new SystemBundleImpl();
- private BundleWiringImpl bundleWiringImpl = new BundleWiringImpl();
+ private final BundleContextImpl bundleContextImpl = new BundleContextImpl();
+ private final SystemBundleImpl systemBundleImpl = new SystemBundleImpl();
+ private final BundleWiringImpl bundleWiringImpl = new BundleWiringImpl();
- private List<URL> bundleLocations = new ArrayList<>();
- private List<Bundle> bundleList = Lists.newArrayList(systemBundleImpl);
+ private final List<URL> bundleLocations = new ArrayList<>();
+ private final List<Bundle> bundleList = new ArrayList<>(List.of(systemBundleImpl));
private ClassLoader classLoader = null;
- private AtomicInteger nextBundleId = new AtomicInteger(1);
+ private final AtomicInteger nextBundleId = new AtomicInteger(1);
@Override
public List<Bundle> installBundle(String bundleLocation) {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java
index fed9f7017ed..2027dcfb60f 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java
@@ -2,7 +2,6 @@
package com.yahoo.tensor;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
@@ -11,7 +10,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
/**
* A mixed tensor type. This is class is currently suitable for serialization
@@ -30,14 +28,14 @@ public class MixedTensor implements Tensor {
private final TensorType type;
/** The list of cells in the tensor */
- private final ImmutableList<Cell> cells;
+ private final List<Cell> cells;
/** An index structure over the cell list */
private final Index index;
- private MixedTensor(TensorType type, ImmutableList<Cell> cells, Index index) {
+ private MixedTensor(TensorType type, List<Cell> cells, Index index) {
this.type = type;
- this.cells = ImmutableList.copyOf(cells);
+ this.cells = List.copyOf(cells);
this.index = index;
}
@@ -91,7 +89,7 @@ public class MixedTensor implements Tensor {
@Override
public Iterator<Double> valueIterator() {
return new Iterator<>() {
- Iterator<Cell> cellIterator = cellIterator();
+ final Iterator<Cell> cellIterator = cellIterator();
@Override
public boolean hasNext() {
return cellIterator.hasNext();
@@ -154,14 +152,14 @@ public class MixedTensor implements Tensor {
@Override
public String toAbbreviatedString(boolean withType, boolean shortForms) {
- return toString(withType, shortForms, Math.max(2, 10 / (type().dimensions().stream().filter(d -> d.isMapped()).count() + 1)));
+ return toString(withType, shortForms, Math.max(2, 10 / (type().dimensions().stream().filter(TensorType.Dimension::isMapped).count() + 1)));
}
private String toString(boolean withType, boolean shortForms, long maxCells) {
if (! shortForms
|| type.rank() == 0
- || type.rank() > 1 && type.dimensions().stream().filter(d -> d.isIndexed()).anyMatch(d -> d.size().isEmpty())
- || type.dimensions().stream().filter(d -> d.isMapped()).count() > 1)
+ || type.rank() > 1 && type.dimensions().stream().filter(TensorType.Dimension::isIndexed).anyMatch(d -> d.size().isEmpty())
+ || type.dimensions().stream().filter(TensorType.Dimension::isMapped).count() > 1)
return Tensor.toStandardString(this, withType, shortForms, maxCells);
return (withType ? type + ":" : "") + index.contentToString(this, maxCells);
@@ -243,7 +241,7 @@ public class MixedTensor implements Tensor {
indexBuilder = new Index.Builder(type);
index = indexBuilder.index();
denseSubtype = new TensorType(type.valueType(),
- type.dimensions().stream().filter(d -> d.isIndexed()).collect(Collectors.toList()));
+ type.dimensions().stream().filter(TensorType.Dimension::isIndexed).toList());
}
public long denseSubspaceSize() {
@@ -290,7 +288,7 @@ public class MixedTensor implements Tensor {
@Override
public MixedTensor build() {
long count = 0;
- ImmutableList.Builder<Cell> builder = new ImmutableList.Builder<>();
+ List<Cell> builder = new ArrayList<>();
for (Map.Entry<TensorAddress, double[]> entry : denseSubspaceMap.entrySet()) {
TensorAddress sparsePart = entry.getKey();
@@ -304,7 +302,7 @@ public class MixedTensor implements Tensor {
count++;
}
}
- return new MixedTensor(type, builder.build(), indexBuilder.build());
+ return new MixedTensor(type, builder, indexBuilder.build());
}
}
@@ -319,7 +317,7 @@ public class MixedTensor implements Tensor {
*/
public static class UnboundBuilder extends Builder {
- private Map<TensorAddress, Double> cells;
+ private final Map<TensorAddress, Double> cells;
private final long[] dimensionBounds;
private UnboundBuilder(TensorType type) {
@@ -394,8 +392,8 @@ public class MixedTensor implements Tensor {
private Index(TensorType type) {
this.type = type;
- this.mappedDimensions = type.dimensions().stream().filter(d -> !d.isIndexed()).collect(Collectors.toList());
- this.indexedDimensions = type.dimensions().stream().filter(d -> d.isIndexed()).collect(Collectors.toList());
+ this.mappedDimensions = type.dimensions().stream().filter(d -> !d.isIndexed()).toList();
+ this.indexedDimensions = type.dimensions().stream().filter(TensorType.Dimension::isIndexed).toList();
this.sparseType = createPartialType(type.valueType(), mappedDimensions);
this.denseType = createPartialType(type.valueType(), indexedDimensions);
}