summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--client/go/jvm/jdk_properties.go2
-rw-r--r--component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java15
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java15
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java3
-rw-r--r--config-model/src/test/cfg/application/embed/services.xml2
-rwxr-xr-xconfig/pom.xml5
-rw-r--r--container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java14
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java114
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java3
-rw-r--r--dist/vespa.spec1
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentType.java15
-rw-r--r--document/src/main/java/com/yahoo/document/StructDataType.java14
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/AnnotationType.java11
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/SpanTree.java21
-rw-r--r--document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java9
-rw-r--r--document/src/main/java/com/yahoo/document/json/TokenBuffer.java40
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/asyncinitializationpolicy.cpp8
-rw-r--r--filedistribution/pom.xml4
-rw-r--r--filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java12
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/Flags.java4
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstallationException.java5
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/ServerRepository.java10
-rw-r--r--metrics-proxy/pom.xml10
-rw-r--r--metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/VespaServices.java5
-rw-r--r--metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java26
-rw-r--r--metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/HttpHandlerTestBase.java8
-rw-r--r--metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/ExternalMetricsTest.java7
-rw-r--r--metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/MetricsPacketTest.java27
-rw-r--r--metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/VespaServicesTest.java5
-rw-r--r--model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java29
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepository.java15
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/bindings/NodeRepositoryNode.java22
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java1
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java3
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java14
-rw-r--r--pom.xml1
-rw-r--r--searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp1
-rw-r--r--vespa_feed_perf/.gitignore2
-rw-r--r--vespa_feed_perf/CMakeLists.txt4
-rw-r--r--vespa_feed_perf/OWNERS1
-rw-r--r--vespa_feed_perf/README1
-rw-r--r--vespa_feed_perf/pom.xml74
-rw-r--r--vespaclient-java/CMakeLists.txt1
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java (renamed from vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java)0
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java (renamed from vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java)0
-rwxr-xr-xvespaclient-java/src/main/sh/vespa-feed-perf (renamed from vespa_feed_perf/src/main/sh/vespa-feed-perf)7
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java (renamed from vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java)15
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/SimpleFeederTest.java (renamed from vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/SimpleFeederTest.java)17
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/SimpleServer.java (renamed from vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/SimpleServer.java)0
-rw-r--r--vespaclient-java/src/test/resources/documentmanager.cfg (renamed from vespa_feed_perf/src/test/resources/documentmanager.cfg)0
-rw-r--r--vespajlib/src/main/java/com/yahoo/collections/ListMap.java21
-rw-r--r--vespajlib/src/main/java/com/yahoo/errorhandling/Results.java7
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java16
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java1
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Argmax.java10
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Argmin.java10
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java37
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/DynamicTensor.java3
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java6
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Matmul.java3
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Merge.java11
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.java29
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/ReduceJoin.java5
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Rename.java10
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/ScalarFunctions.java10
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Softmax.java3
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/XwPlusB.java3
-rw-r--r--vespajlib/src/main/java/com/yahoo/text/StringUtilities.java10
-rw-r--r--vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java5
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java7
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java17
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java7
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/functions/MatmulTestCase.java7
-rw-r--r--vespajlib/src/test/java/com/yahoo/text/Benchmark.java108
-rw-r--r--vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java76
-rw-r--r--vespalib/src/vespa/vespalib/coro/schedule.h7
78 files changed, 312 insertions, 743 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc9fa40b121..4f7d7a0c0bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -152,7 +152,6 @@ add_subdirectory(vespaclient-core)
add_subdirectory(vespaclient-java)
add_subdirectory(vespa-feed-client)
add_subdirectory(vespa-feed-client-cli)
-add_subdirectory(vespa_feed_perf)
add_subdirectory(vespajlib)
add_subdirectory(vespalib)
add_subdirectory(vespalog)
diff --git a/client/go/jvm/jdk_properties.go b/client/go/jvm/jdk_properties.go
index 90b243e8a85..7656d87db3d 100644
--- a/client/go/jvm/jdk_properties.go
+++ b/client/go/jvm/jdk_properties.go
@@ -13,7 +13,7 @@ func (opts *Options) AddCommonJdkProperties() {
secOvr := defaults.UnderVespaHome("conf/vespa/java.security.override")
opts.fixSpec.FixDir(tmpDir)
opts.AddOption("-Djava.io.tmpdir=" + tmpDir)
- opts.AddOption("-Djava.library.path=" + libDir)
+ opts.AddOption("-Djava.library.path=" + libDir + ":/opt/vespa-deps/lib64")
opts.AddOption("-Djava.security.properties=" + secOvr)
opts.AddOption("-Djava.awt.headless=true")
opts.AddOption("-Dsun.rmi.dgc.client.gcInterval=3600000")
diff --git a/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java b/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java
index 1dddcbcc461..a64d6eb1090 100644
--- a/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java
+++ b/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.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.provider;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.yahoo.component.ComponentId;
import com.yahoo.component.ComponentSpecification;
@@ -56,17 +55,9 @@ public class ComponentRegistry<COMPONENT> {
if (frozen) throw new IllegalStateException("Cannot modify a frozen component registry");
Map<String, Map<Version, COMPONENT>> componentVersionsByName =
- componentsByNameByNamespace.get(id.getNamespace());
- if (componentVersionsByName == null) {
- componentVersionsByName = new LinkedHashMap<>();
- componentsByNameByNamespace.put(id.getNamespace(), componentVersionsByName);
- }
+ componentsByNameByNamespace.computeIfAbsent(id.getNamespace(), k -> new LinkedHashMap<>());
- Map<Version, COMPONENT> componentVersions = componentVersionsByName.get(id.getName());
- if (componentVersions == null) {
- componentVersions = new LinkedHashMap<>();
- componentVersionsByName.put(id.getName(), componentVersions);
- }
+ Map<Version, COMPONENT> componentVersions = componentVersionsByName.computeIfAbsent(id.getName(), k -> new LinkedHashMap<>());
componentVersions.put(id.getVersion(), component);
componentsById.put(id, component);
@@ -162,7 +153,7 @@ public class ComponentRegistry<COMPONENT> {
* Returns an unmodifiable snapshot of all components present in this registry.
*/
public List<COMPONENT> allComponents() {
- return ImmutableList.copyOf(componentsById.values());
+ return List.copyOf(componentsById.values());
}
/**
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java b/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java
index e95527d646a..7955a11ce45 100644
--- a/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java
+++ b/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.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.application.api;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -50,10 +49,10 @@ public class Notifications {
return none;
ImmutableMap.Builder<When, List<String>> emailAddresses = ImmutableMap.builder();
- emailAddressesByWhen.forEach((when, addresses) -> emailAddresses.put(when, ImmutableList.copyOf(addresses)));
+ emailAddressesByWhen.forEach((when, addresses) -> emailAddresses.put(when, List.copyOf(addresses)));
ImmutableMap.Builder<When, List<Role>> emailRoles = ImmutableMap.builder();
- emailRolesByWhen.forEach((when, roles) -> emailRoles.put(when, ImmutableList.copyOf(roles)));
+ emailRolesByWhen.forEach((when, roles) -> emailRoles.put(when, List.copyOf(roles)));
return new Notifications(emailAddresses.build(), emailRoles.build());
}
@@ -122,11 +121,11 @@ public class Notifications {
}
public static When fromValue(String value) {
- switch (value) {
- case "failing": return failing;
- case "failing-commit": return failingCommit;
- default: throw new IllegalArgumentException("Unknown value '" + value + "'.");
- }
+ return switch (value) {
+ case "failing" -> failing;
+ case "failing-commit" -> failingCommit;
+ default -> throw new IllegalArgumentException("Unknown value '" + value + "'.");
+ };
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
index 8094eae881f..9729ee59c5c 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
@@ -301,9 +301,6 @@ public abstract class Container extends AbstractService implements
}
public Optional<String> getStartupCommand() {
- if (useOldStartupScript) {
- return Optional.of("PRELOAD=" + getPreLoad() + " exec vespa-start-container-daemon " + getJvmOptions() + " ");
- }
return Optional.of("PRELOAD=" + getPreLoad() + " exec ${VESPA_HOME}/libexec/vespa/script-utils vespa-start-container-daemon " + getJvmOptions() + " ");
}
diff --git a/config-model/src/test/cfg/application/embed/services.xml b/config-model/src/test/cfg/application/embed/services.xml
index cdbcfd67f02..fcb1f10f32c 100644
--- a/config-model/src/test/cfg/application/embed/services.xml
+++ b/config-model/src/test/cfg/application/embed/services.xml
@@ -4,7 +4,7 @@
<container version="1.0">
- <component id="transformer" class="ai.vespa.embedding.BertBaseEmbedder" bindle="model-integration">
+ <component id="transformer" class="ai.vespa.embedding.BertBaseEmbedder" bundle="model-integration">
<config name="embedding.bert-base-embedder">
<!-- model specifics -->
<transformerModel model-id="minilm-l6-v2" url="application-url"/>
diff --git a/config/pom.xml b/config/pom.xml
index 1f90d374d88..28eb45fd406 100755
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -21,11 +21,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>annotations</artifactId>
<version>${project.version}</version>
diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java b/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java
index 9c2d703e1a8..0b8c0c8c48c 100644
--- a/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java
+++ b/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.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.jdisc;
-import com.google.common.util.concurrent.AtomicDouble;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Injector;
@@ -58,7 +57,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Phaser;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -79,8 +77,8 @@ public final class ConfiguredApplication implements Application {
private final String configId;
private final OsgiFramework osgiFramework;
private final com.yahoo.jdisc.Timer timerSingleton;
- private final AtomicBoolean dumpHeapOnShutdownTimeout = new AtomicBoolean(false);
- private final AtomicDouble shutdownTimeoutS = new AtomicDouble(50.0);
+ private volatile boolean dumpHeapOnShutdownTimeout = false;
+ private volatile double shutdownTimeoutS = 50.0;
// Subscriber that is used when this is not a standalone-container. Subscribes
// to config to make sure that container will be registered in slobrok (by {@link com.yahoo.jrt.slobrok.api.Register})
// if slobrok config changes (typically slobroks moving to other nodes)
@@ -286,8 +284,8 @@ public final class ConfiguredApplication implements Application {
}
private void reconfigure(QrConfig.Shutdown shutdown) {
- dumpHeapOnShutdownTimeout.set(shutdown.dumpHeapOnTimeout());
- shutdownTimeoutS.set(shutdown.timeout());
+ dumpHeapOnShutdownTimeout = shutdown.dumpHeapOnTimeout();
+ shutdownTimeoutS = shutdown.timeout();
}
private void initializeAndActivateContainer(ContainerBuilder builder, Runnable cleanupTask) {
@@ -429,7 +427,7 @@ public final class ConfiguredApplication implements Application {
@Override
public void stop() {
log.info("Stop: Initiated");
- shutdownDeadline.schedule((long)(shutdownTimeoutS.get() * 1000), dumpHeapOnShutdownTimeout.get());
+ shutdownDeadline.schedule((long)(shutdownTimeoutS * 1000), dumpHeapOnShutdownTimeout);
stopServersAndAwaitTermination();
log.info("Stop: Finished");
}
@@ -438,7 +436,7 @@ public final class ConfiguredApplication implements Application {
log.info("PrepareStop: Initiated");
long timeoutMillis = (long) (request.parameters().get(0).asDouble() * 1000);
try (ShutdownDeadline ignored =
- new ShutdownDeadline(configId).schedule(timeoutMillis, dumpHeapOnShutdownTimeout.get())) {
+ new ShutdownDeadline(configId).schedule(timeoutMillis, dumpHeapOnShutdownTimeout)) {
stopServersAndAwaitTermination();
log.info("PrepareStop: Finished");
} catch (Exception e) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java
index 47125d198e1..5488334c838 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java
@@ -83,15 +83,15 @@ public class ValidateSortingSearcher extends Searcher {
}
private static Sorting.UcaSorter.Strength config2Strength(AttributesConfig.Attribute.Sortstrength.Enum s) {
- if(s == AttributesConfig.Attribute.Sortstrength.PRIMARY) {
+ if (s == AttributesConfig.Attribute.Sortstrength.PRIMARY) {
return Sorting.UcaSorter.Strength.PRIMARY;
- } else if(s == AttributesConfig.Attribute.Sortstrength.SECONDARY) {
+ } else if (s == AttributesConfig.Attribute.Sortstrength.SECONDARY) {
return Sorting.UcaSorter.Strength.SECONDARY;
- } else if(s == AttributesConfig.Attribute.Sortstrength.TERTIARY) {
+ } else if (s == AttributesConfig.Attribute.Sortstrength.TERTIARY) {
return Sorting.UcaSorter.Strength.TERTIARY;
- } else if(s == AttributesConfig.Attribute.Sortstrength.QUATERNARY) {
+ } else if (s == AttributesConfig.Attribute.Sortstrength.QUATERNARY) {
return Sorting.UcaSorter.Strength.QUATERNARY;
- } else if(s == AttributesConfig.Attribute.Sortstrength.IDENTICAL) {
+ } else if (s == AttributesConfig.Attribute.Sortstrength.IDENTICAL) {
return Sorting.UcaSorter.Strength.IDENTICAL;
}
return Sorting.UcaSorter.Strength.PRIMARY;
@@ -117,73 +117,69 @@ public class ValidateSortingSearcher extends Searcher {
for (Sorting.FieldOrder f : l) {
String name = f.getFieldName();
if ("[rank]".equals(name) || "[docid]".equals(name)) {
- // built-in constants - ok
- } else if ("[relevance]".equals(name)) {
- // built-in constant '[relevance]' must map to '[rank]'
- f.getSorter().setName("[rank]");
- } else if ("[relevancy]".equals(name)) {
- // built-in constant '[relevancy]' must map to '[rank]'
+ // built-in constants
+ } else if ("[relevance]".equals(name) || "[relevancy]".equals(name)) { // aliases
f.getSorter().setName("[rank]");
} else if (names.containsKey(name)) {
AttributesConfig.Attribute attrConfig = names.get(name);
- if (attrConfig != null) {
- if (f.getSortOrder() == Sorting.Order.UNDEFINED) {
- f.setAscending(attrConfig.sortascending());
- }
- if (f.getSorter().getClass().equals(Sorting.AttributeSorter.class)) {
- // This indicates that it shall use default.
- if ((attrConfig.datatype() == AttributesConfig.Attribute.Datatype.STRING)) {
- if (attrConfig.sortfunction() == AttributesConfig.Attribute.Sortfunction.UCA) {
- String locale = attrConfig.sortlocale();
- if (locale == null || locale.isEmpty()) {
- locale = queryLocale;
- }
- // can only use UcaSorter if we have knowledge about wanted locale
- if (locale != null) {
- f.setSorter(new Sorting.UcaSorter(name, locale, Sorting.UcaSorter.Strength.UNDEFINED));
- } else {
- // wanted UCA but no locale known, so use lowercase as fallback
- f.setSorter(new Sorting.LowerCaseSorter(name));
- }
- } else if (attrConfig.sortfunction() == AttributesConfig.Attribute.Sortfunction.LOWERCASE) {
- f.setSorter(new Sorting.LowerCaseSorter(name));
- } else if (attrConfig.sortfunction() == AttributesConfig.Attribute.Sortfunction.RAW) {
- f.setSorter(new Sorting.RawSorter(name));
+ if (attrConfig == null)
+ return ErrorMessage.createInvalidQueryParameter("Cluster '" + getClusterName() +
+ "' has no attribute config for field '" + name + "'");
+ if (f.getSortOrder() == Sorting.Order.UNDEFINED) {
+ f.setAscending(attrConfig.sortascending());
+ }
+ if (f.getSorter().getClass().equals(Sorting.AttributeSorter.class)) {
+ // This indicates that it shall use default.
+ if ((attrConfig.datatype() == AttributesConfig.Attribute.Datatype.STRING)) {
+ if (attrConfig.sortfunction() == AttributesConfig.Attribute.Sortfunction.UCA) {
+ String locale = attrConfig.sortlocale();
+ if (locale == null || locale.isEmpty()) {
+ locale = queryLocale;
+ }
+ // can only use UcaSorter if we have knowledge about wanted locale
+ if (locale != null) {
+ f.setSorter(new Sorting.UcaSorter(name, locale, Sorting.UcaSorter.Strength.UNDEFINED));
} else {
- // default if no config found for this string attribute
+ // wanted UCA but no locale known, so use lowercase as fallback
f.setSorter(new Sorting.LowerCaseSorter(name));
}
+ } else if (attrConfig.sortfunction() == AttributesConfig.Attribute.Sortfunction.LOWERCASE) {
+ f.setSorter(new Sorting.LowerCaseSorter(name));
+ } else if (attrConfig.sortfunction() == AttributesConfig.Attribute.Sortfunction.RAW) {
+ f.setSorter(new Sorting.RawSorter(name));
+ } else {
+ // default if no config found for this string attribute
+ f.setSorter(new Sorting.LowerCaseSorter(name));
}
}
- if (f.getSorter() instanceof Sorting.UcaSorter sorter) {
- String locale = sorter.getLocale();
+ }
+ if (f.getSorter() instanceof Sorting.UcaSorter sorter) {
+ String locale = sorter.getLocale();
- if (locale == null || locale.isEmpty()) {
- // first fallback
- locale = attrConfig.sortlocale();
- }
- if (locale == null || locale.isEmpty()) {
- // second fallback
- locale = queryLocale;
- }
- // final fallback
- if (locale == null || locale.isEmpty()) {
- locale = "en_US";
- }
+ if (locale == null || locale.isEmpty()) {
+ // first fallback
+ locale = attrConfig.sortlocale();
+ }
+ if (locale == null || locale.isEmpty()) {
+ // second fallback
+ locale = queryLocale;
+ }
+ // final fallback
+ if (locale == null || locale.isEmpty()) {
+ locale = "en_US";
+ }
- Sorting.UcaSorter.Strength strength = sorter.getStrength();
- if (sorter.getStrength() == Sorting.UcaSorter.Strength.UNDEFINED) {
- strength = config2Strength(attrConfig.sortstrength());
- }
- if ((sorter.getStrength() == Sorting.UcaSorter.Strength.UNDEFINED) || (sorter.getLocale() == null) || sorter.getLocale().isEmpty()) {
- sorter.setLocale(locale, strength);
- }
+ Sorting.UcaSorter.Strength strength = sorter.getStrength();
+ if (sorter.getStrength() == Sorting.UcaSorter.Strength.UNDEFINED) {
+ strength = config2Strength(attrConfig.sortstrength());
+ }
+ if ((sorter.getStrength() == Sorting.UcaSorter.Strength.UNDEFINED) || (sorter.getLocale() == null) || sorter.getLocale().isEmpty()) {
+ sorter.setLocale(locale, strength);
}
- } else {
- return ErrorMessage.createInvalidQueryParameter("The cluster " + getClusterName() + " has attribute config for field: " + name);
}
} else {
- return ErrorMessage.createInvalidQueryParameter("The cluster " + getClusterName() + " has no sortable attribute named: " + name);
+ return ErrorMessage.createInvalidQueryParameter("Cluster '" + getClusterName() +
+ "' has no sortable attribute named '" + name + "'");
}
}
return null;
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java
index bc27d736ad4..f388a148ffb 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.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.deployment;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
@@ -32,7 +31,7 @@ public class RunLog {
ImmutableMap.Builder<Step, List<LogEntry>> builder = ImmutableMap.builder();
log.forEach((step, entries) -> {
if ( ! entries.isEmpty())
- builder.put(step, ImmutableList.copyOf(entries));
+ builder.put(step, List.copyOf(entries));
});
OptionalLong lastId = log.values().stream()
.flatMap(List::stream)
diff --git a/dist/vespa.spec b/dist/vespa.spec
index 8cfe63dda7d..333ec7b57fc 100644
--- a/dist/vespa.spec
+++ b/dist/vespa.spec
@@ -617,7 +617,6 @@ fi
%{_prefix}/lib/jars/searchlib.jar
%{_prefix}/lib/jars/service-monitor-jar-with-dependencies.jar
%{_prefix}/lib/jars/tenant-cd-api-jar-with-dependencies.jar
-%{_prefix}/lib/jars/vespa_feed_perf-jar-with-dependencies.jar
%{_prefix}/lib/jars/vespa-osgi-testrunner-jar-with-dependencies.jar
%{_prefix}/lib/jars/vespa-testrunner-components.jar
%{_prefix}/lib/jars/vespa-testrunner-components-jar-with-dependencies.jar
diff --git a/document/src/main/java/com/yahoo/document/DocumentType.java b/document/src/main/java/com/yahoo/document/DocumentType.java
index 0f771e4d55a..bec08837a84 100644
--- a/document/src/main/java/com/yahoo/document/DocumentType.java
+++ b/document/src/main/java/com/yahoo/document/DocumentType.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.document;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.yahoo.document.datatypes.FieldValue;
import com.yahoo.document.fieldset.AllFields;
@@ -38,9 +37,9 @@ public class DocumentType extends StructuredDataType {
public static final int classId = registerClass(Ids.document + 58, DocumentType.class);
private StructDataType contentStructType;
private List<DocumentType> inherits = new ArrayList<>(1);
- private Map<String, Set<Field>> fieldSets = new HashMap<>();
+ private final Map<String, Set<Field>> fieldSets = new HashMap<>();
private final Set<String> importedFieldNames;
- private Map<String, StructDataType> declaredStructTypes = new HashMap<>();
+ private final Map<String, StructDataType> declaredStructTypes = new HashMap<>();
/**
* Creates a new document type and registers it with the document type manager.
@@ -101,10 +100,9 @@ public class DocumentType extends StructuredDataType {
@Override
public boolean isValueCompatible(FieldValue value) {
- if (!(value instanceof Document)) {
+ if (!(value instanceof Document doc)) {
return false;
}
- Document doc = (Document) value;
if (doc.getDataType().inherits(this)) {
//the value is of this type; or the supertype of the value is of this type, etc....
return true;
@@ -330,7 +328,7 @@ public class DocumentType extends StructuredDataType {
for (DocumentType type : inherits) {
names.add(type.getDataTypeName());
}
- return ImmutableList.copyOf(names).listIterator();
+ return List.copyOf(names).listIterator();
}
/**
@@ -433,7 +431,7 @@ public class DocumentType extends StructuredDataType {
}
collection.addAll(contentStructType.getFields());
- return ImmutableList.copyOf(collection);
+ return List.copyOf(collection);
}
private Set<Field> getAllUniqueFields() {
@@ -486,8 +484,7 @@ public class DocumentType extends StructuredDataType {
}
public boolean equals(Object o) {
- if (!(o instanceof DocumentType)) return false;
- DocumentType other = (DocumentType) o;
+ if (!(o instanceof DocumentType other)) return false;
// Ignore whether one of them have added inheritance to super Document.0 type
if (super.equals(o) && contentStructType.equals(other.contentStructType)) {
if ((inherits.size() > 1 || other.inherits.size() > 1) ||
diff --git a/document/src/main/java/com/yahoo/document/StructDataType.java b/document/src/main/java/com/yahoo/document/StructDataType.java
index 34967cf6f51..2af34711851 100644
--- a/document/src/main/java/com/yahoo/document/StructDataType.java
+++ b/document/src/main/java/com/yahoo/document/StructDataType.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.document;
-import com.google.common.collect.ImmutableList;
import com.yahoo.document.datatypes.FieldValue;
import com.yahoo.document.datatypes.Struct;
import com.yahoo.vespa.objects.Ids;
@@ -9,6 +8,7 @@ import com.yahoo.vespa.objects.Ids;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
/**
* @author Einar M R Rosenvinge
@@ -98,7 +98,7 @@ public class StructDataType extends BaseStructDataType {
Collection<Field> fieldsBuilder = new ArrayList<>();
fieldsBuilder.addAll(super.getFields());
fieldsBuilder.addAll(superType.getFields());
- return ImmutableList.copyOf(fieldsBuilder);
+ return List.copyOf(fieldsBuilder);
}
public Collection<Field> getFieldsThisTypeOnly() {
@@ -117,10 +117,9 @@ public class StructDataType extends BaseStructDataType {
@Override
public boolean isValueCompatible(FieldValue value) {
- if (!(value instanceof Struct)) {
+ if (!(value instanceof Struct structValue)) {
return false;
}
- Struct structValue = (Struct) value;
if (structValue.getDataType().inherits(this)) {
//the value is of this type; or the supertype of the value is of this type, etc....
return true;
@@ -142,9 +141,9 @@ public class StructDataType extends BaseStructDataType {
public Collection<StructDataType> getInheritedTypes() {
if (superType == null) {
- return ImmutableList.of();
+ return List.of();
}
- return ImmutableList.of(superType);
+ return List.of(superType);
}
public boolean inherits(StructDataType type) {
@@ -156,10 +155,9 @@ public class StructDataType extends BaseStructDataType {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof StructDataType)) return false;
+ if (!(o instanceof StructDataType that)) return false;
if (!super.equals(o)) return false;
- StructDataType that = (StructDataType) o;
if (superType != null ? !superType.equals(that.superType) : that.superType != null) return false;
return true;
}
diff --git a/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java b/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java
index 4acc9c00384..88e6bd7822a 100644
--- a/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java
+++ b/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java
@@ -1,12 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.annotation;
-import com.google.common.collect.ImmutableList;
import com.yahoo.collections.MD5;
import com.yahoo.document.DataType;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
/**
* An AnnotationType describes a certain type of annotations; they are
@@ -124,9 +123,9 @@ public class AnnotationType implements Comparable<AnnotationType> {
public Collection<AnnotationType> getInheritedTypes() {
if (superType == null) {
- return ImmutableList.of();
+ return List.of();
}
- return ImmutableList.of(superType);
+ return List.of(superType);
}
public boolean inherits(AnnotationType type) {
@@ -138,9 +137,7 @@ public class AnnotationType implements Comparable<AnnotationType> {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof AnnotationType)) return false;
-
- AnnotationType that = (AnnotationType) o;
+ if (!(o instanceof AnnotationType that)) return false;
return name.equals(that.name);
}
diff --git a/document/src/main/java/com/yahoo/document/annotation/SpanTree.java b/document/src/main/java/com/yahoo/document/annotation/SpanTree.java
index b03f587d839..d63616130e2 100644
--- a/document/src/main/java/com/yahoo/document/annotation/SpanTree.java
+++ b/document/src/main/java/com/yahoo/document/annotation/SpanTree.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.document.annotation;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultiset;
import com.yahoo.document.CollectionDataType;
import com.yahoo.document.Field;
@@ -63,7 +62,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
setRoot(new SpanList());
}
- @SuppressWarnings("unchecked")
public SpanTree(SpanTree otherToCopy) {
name = otherToCopy.name;
setRoot(copySpan(otherToCopy.root));
@@ -250,7 +248,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
* total number of Annotations, and m is the number of SpanNodes that had been removed from the tree.
* The lower bound is Omega(n), if no SpanNodes had been removed from the tree.
*/
- @SuppressWarnings("unchecked")
public void cleanup() {
Map<Annotation, Annotation> removedAnnotations = removeAnnotationsThatPointToInvalidSpanNodes();
@@ -269,9 +266,8 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
}
FieldValue value = a.getFieldValue();
- if (value instanceof AnnotationReference) {
+ if (value instanceof AnnotationReference ref) {
//the annotation "a" has a reference
- AnnotationReference ref = (AnnotationReference) value;
if (removedAnnotations.get(ref.getReference()) != null) {
//this reference refers to a dead annotation
ref.setReference(null);
@@ -367,7 +363,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
return false;
}
- @SuppressWarnings("unchecked")
private Map<Annotation, Annotation> removeAnnotationsThatPointToInvalidSpanNodes() {
Map<Annotation, Annotation> removedAnnotations = new IdentityHashMap<Annotation, Annotation>();
@@ -412,7 +407,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
annotations.annotate(annotation);
}
- @SuppressWarnings("unchecked")
private Collection<Annotation> getAnnotations() {
return annotations.annotations();
}
@@ -548,7 +542,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
* Returns an Iterator over all annotations in this tree.&nbsp;Note that the iteration order is non-deterministic.
* @return an Iterator over all annotations in this tree.
*/
- @SuppressWarnings("unchecked")
public Iterator<Annotation> iterator() {
return annotations.annotations().iterator();
}
@@ -559,7 +552,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
* @param node the node to return annotations for.
* @return an Iterator over all annotations that annotate the given node.
*/
- @SuppressWarnings("unchecked")
public Iterator<Annotation> iterator(SpanNode node) {
return annotations.iterator(node);
}
@@ -570,7 +562,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
* @param node the node to recursively return annotations for.
* @return a recursive Iterator over all annotations that annotate the given node and its subnodes.
*/
- @SuppressWarnings("unchecked")
public Iterator<Annotation> iteratorRecursive(SpanNode node) {
return annotations.iteratorRecursive(node);
}
@@ -642,10 +633,10 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
public Collection<IndexKey> getCurrentIndexes() {
if (annotations instanceof AnnotationType2AnnotationContainer)
- return ImmutableList.of(IndexKey.ANNOTATION_TYPE);
+ return List.of(IndexKey.ANNOTATION_TYPE);
if (annotations instanceof SpanNode2AnnotationContainer)
- return ImmutableList.of(IndexKey.SPAN_NODE);
- return ImmutableList.of();
+ return List.of(IndexKey.SPAN_NODE);
+ return List.of();
}
@Override
@@ -656,9 +647,8 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof SpanTree)) return false;
+ if (!(o instanceof SpanTree tree)) return false;
- SpanTree tree = (SpanTree) o;
if (!annotationsEquals(tree)) return false;
if (!name.equals(tree.name)) return false;
if (!root.equals(tree.root)) return false;
@@ -666,7 +656,6 @@ public class SpanTree implements Iterable<Annotation>, SpanNodeParent, Comparabl
return true;
}
- @SuppressWarnings("unchecked")
private boolean annotationsEquals(SpanTree tree) {
List<Annotation> annotationCollection = new LinkedList<Annotation>(getAnnotations());
List<Annotation> otherAnnotations = new LinkedList<Annotation>(tree.getAnnotations());
diff --git a/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java
index 51b068b4712..6133c9ca0ad 100644
--- a/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java
+++ b/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.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.document.datatypes;
-import com.google.common.collect.ImmutableList;
import com.yahoo.collections.CollectionComparator;
import com.yahoo.document.DataType;
import com.yahoo.document.Field;
@@ -16,6 +15,7 @@ import com.yahoo.vespa.objects.Ids;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -142,9 +142,9 @@ public class StringFieldValue extends FieldValue {
*/
public Collection<SpanTree> getSpanTrees() {
if (spanTrees == null) {
- return ImmutableList.of();
+ return List.of();
}
- return ImmutableList.copyOf(spanTrees.values());
+ return List.copyOf(spanTrees.values());
}
/** Returns the map of spantrees. Might be null. */
@@ -236,9 +236,8 @@ public class StringFieldValue extends FieldValue {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof StringFieldValue)) return false;
+ if (!(o instanceof StringFieldValue that)) return false;
if (!super.equals(o)) return false;
- StringFieldValue that = (StringFieldValue) o;
if (!Objects.equals(spanTrees, that.spanTrees)) return false;
if (!Objects.equals(value, that.value)) return false;
return true;
diff --git a/document/src/main/java/com/yahoo/document/json/TokenBuffer.java b/document/src/main/java/com/yahoo/document/json/TokenBuffer.java
index e6d2021f90b..58ceeec4f4c 100644
--- a/document/src/main/java/com/yahoo/document/json/TokenBuffer.java
+++ b/document/src/main/java/com/yahoo/document/json/TokenBuffer.java
@@ -89,10 +89,6 @@ public class TokenBuffer {
bufferJsonStruct(first, tokens, JsonToken.START_OBJECT);
}
- public void bufferArray(JsonToken first, JsonParser tokens) {
- bufferJsonStruct(first, tokens, JsonToken.START_ARRAY);
- }
-
private void bufferJsonStruct(JsonToken first, JsonParser tokens, JsonToken firstToken) {
int localNesting = 0;
JsonToken t = first;
@@ -150,42 +146,6 @@ public class TokenBuffer {
return nesting;
}
- public String dumpContents() {
- StringBuilder b = new StringBuilder();
- b.append("[nesting: ").append(nesting()).append("\n");
- for (Token t : buffer) {
- b.append("(").append(t.token).append(", \"").append(t.name).append("\", \"").append(t.text).append("\")\n");
- }
- b.append("]\n");
- return b.toString();
- }
-
- public void fastForwardToEndObject() {
- JsonToken t = currentToken();
- while (t != JsonToken.END_OBJECT) {
- t = next();
- }
- }
-
- public TokenBuffer prefetchCurrentElement() {
- Deque<Token> copy = new ArrayDeque<>();
-
- if (currentToken().isScalarValue()) {
- copy.add(buffer.peekFirst());
- } else {
- int localNesting = nesting();
- int nestingBarrier = localNesting;
- for (Token t : buffer) {
- copy.add(t);
- localNesting += nestingOffset(t.token);
- if (localNesting < nestingBarrier) {
- break;
- }
- }
- }
- return new TokenBuffer(copy);
- }
-
public Token prefetchScalar(String name) {
int localNesting = nesting();
int nestingBarrier = localNesting;
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/asyncinitializationpolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/asyncinitializationpolicy.cpp
index ea3889bfd5e..01a300badab 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/asyncinitializationpolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/asyncinitializationpolicy.cpp
@@ -71,13 +71,13 @@ currentPolicyInitError(vespalib::stringref error) {
void
AsyncInitializationPolicy::select(mbus::RoutingContext& context)
{
- if (_syncInit && _state != State::DONE) {
- initSynchronous();
- }
-
{
std::lock_guard lock(_lock);
+ if (_syncInit && _state != State::DONE) {
+ initSynchronous();
+ }
+
if (_state == State::NOT_STARTED || _state == State::FAILED) {
// Only 1 task may be queued to the executor at any point in time.
// This is maintained by only scheduling a task when either no task
diff --git a/filedistribution/pom.xml b/filedistribution/pom.xml
index 74e06d4a9e3..6485919b14b 100644
--- a/filedistribution/pom.xml
+++ b/filedistribution/pom.xml
@@ -43,10 +43,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java
index efb845bafe7..b6f84b979f5 100644
--- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java
+++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.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.filedistribution;
-import com.google.common.io.ByteStreams;
import net.jpountz.lz4.LZ4BlockInputStream;
import net.jpountz.lz4.LZ4BlockOutputStream;
import org.apache.commons.compress.archivers.ArchiveEntry;
@@ -87,9 +86,9 @@ public class FileReferenceCompressor {
if (!parent.exists() && !parent.mkdirs()) {
log.log(Level.WARNING, "Could not create dir " + parent.getAbsolutePath());
}
- FileOutputStream fos = new FileOutputStream(outFile);
- ByteStreams.copy(archiveInputStream, fos);
- fos.close();
+ try (FileOutputStream fos = new FileOutputStream(outFile)) {
+ archiveInputStream.transferTo(fos);
+ }
}
entries++;
}
@@ -111,9 +110,10 @@ public class FileReferenceCompressor {
}
private static void writeFileToTar(ArchiveOutputStream taos, File baseDir, File file) throws IOException {
- log.log(Level.FINEST, () -> "Adding file to tar: " + baseDir.toPath().relativize(file.toPath()).toString());
taos.putArchiveEntry(taos.createArchiveEntry(file, baseDir.toPath().relativize(file.toPath()).toString()));
- ByteStreams.copy(new FileInputStream(file), taos);
+ try (FileInputStream inputStream = new FileInputStream(file)) {
+ inputStream.transferTo(taos);
+ }
taos.closeArchiveEntry();
}
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
index a53f13e1303..ef3543c8c27 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
@@ -290,14 +290,14 @@ public class Flags {
public static final UnboundListFlag<String> FILE_DISTRIBUTION_ACCEPTED_COMPRESSION_TYPES = defineListFlag(
"file-distribution-accepted-compression-types", List.of("gzip", "lz4"), String.class,
- List.of("hmusum"), "2022-07-05", "2022-12-01",
+ List.of("hmusum"), "2022-07-05", "2023-02-01",
"´List of accepted compression types used when asking for a file reference. Valid values: gzip, lz4",
"Takes effect on restart of service",
APPLICATION_ID);
public static final UnboundListFlag<String> FILE_DISTRIBUTION_COMPRESSION_TYPES_TO_SERVE = defineListFlag(
"file-distribution-compression-types-to-use", List.of("lz4", "gzip"), String.class,
- List.of("hmusum"), "2022-07-05", "2022-12-01",
+ List.of("hmusum"), "2022-07-05", "2023-02-01",
"List of compression types to use (in preferred order), matched with accepted compression types when serving file references. Valid values: gzip, lz4",
"Takes effect on restart of service",
APPLICATION_ID);
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstallationException.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstallationException.java
index 6b3f4d6e7d7..ab75b499e20 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstallationException.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstallationException.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.jdisc.application;
-import com.google.common.collect.ImmutableList;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
/**
@@ -25,7 +22,7 @@ public final class BundleInstallationException extends BundleException {
public BundleInstallationException(Collection<Bundle> installedBundles, Throwable cause) {
super(cause.getMessage(), cause);
- this.installedBundles = ImmutableList.copyOf(installedBundles);
+ this.installedBundles = List.copyOf(installedBundles);
}
public List<Bundle> installedBundles() {
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ServerRepository.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ServerRepository.java
index 39e7eb29c0f..b6121337e3d 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ServerRepository.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ServerRepository.java
@@ -1,12 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.application;
-import com.google.common.collect.ImmutableList;
import com.yahoo.jdisc.Container;
import com.yahoo.jdisc.service.ServerProvider;
import org.osgi.framework.Bundle;
-import java.util.*;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import java.util.logging.Logger;
/**
@@ -25,7 +27,7 @@ public class ServerRepository implements Iterable<ServerProvider> {
this.guice = guice;
}
- public Iterable<ServerProvider> activate() { return ImmutableList.copyOf(servers); }
+ public Iterable<ServerProvider> activate() { return List.copyOf(servers); }
public List<ServerProvider> installAll(Bundle bundle, Iterable<String> serverNames) throws ClassNotFoundException {
List<ServerProvider> lst = new LinkedList<>();
@@ -65,7 +67,7 @@ public class ServerRepository implements Iterable<ServerProvider> {
}
public Collection<ServerProvider> collection() {
- return Collections.unmodifiableCollection(servers);
+ return List.copyOf(servers);
}
@Override
diff --git a/metrics-proxy/pom.xml b/metrics-proxy/pom.xml
index c3866d3e592..ee1439fb5f6 100644
--- a/metrics-proxy/pom.xml
+++ b/metrics-proxy/pom.xml
@@ -31,16 +31,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>annotations</artifactId>
<version>${project.version}</version>
diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/VespaServices.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/VespaServices.java
index 4318a689ba8..5b9e1e67657 100644
--- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/VespaServices.java
+++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/VespaServices.java
@@ -4,11 +4,9 @@ package ai.vespa.metricsproxy.service;
import ai.vespa.metricsproxy.core.MonitoringConfig;
import ai.vespa.metricsproxy.metric.model.DimensionId;
import ai.vespa.metricsproxy.service.VespaServicesConfig.Service;
-import com.google.common.annotations.VisibleForTesting;
import com.yahoo.component.annotation.Inject;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
@@ -39,7 +37,6 @@ public class VespaServices {
updateServices(services);
}
- @VisibleForTesting
public VespaServices(List<VespaService> services) {
this.services = services;
sentinel = null;
@@ -74,7 +71,7 @@ public class VespaServices {
* @return A list of VespaService objects
*/
public List<VespaService> getVespaServices() {
- return Collections.unmodifiableList(services);
+ return List.copyOf(services);
}
/**
diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java
index 9e5a24ccd3c..70f126a8514 100644
--- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java
+++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java
@@ -18,12 +18,10 @@ import ai.vespa.metricsproxy.service.DownService;
import ai.vespa.metricsproxy.service.DummyService;
import ai.vespa.metricsproxy.service.VespaService;
import ai.vespa.metricsproxy.service.VespaServices;
-import com.google.common.collect.ImmutableList;
import org.junit.Before;
import org.junit.Test;
import java.time.Instant;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -48,7 +46,7 @@ public class MetricsManagerTest {
private static final String SERVICE_0_ID = "dummy/id/0";
private static final String SERVICE_1_ID = "dummy/id/1";
- private static final List<VespaService> testServices = ImmutableList.of(
+ private static final List<VespaService> testServices = List.of(
new DummyService(0, SERVICE_0_ID),
new DummyService(1, SERVICE_1_ID));
@@ -64,7 +62,7 @@ public class MetricsManagerTest {
public void service_that_is_down_has_a_separate_metrics_packet() {
// Reset to use only the service that is down
var downService = new DownService(HealthMetric.getDown("No response"));
- List<VespaService> testServices = Collections.singletonList(downService);
+ List<VespaService> testServices = List.of(downService);
MetricsManager metricsManager = TestUtil.createMetricsManager(new VespaServices(testServices),
getMetricsConsumers(),getApplicationDimensions(), getNodeDimensions());
@@ -140,9 +138,9 @@ public class MetricsManagerTest {
// TODO: test that non-whitelisted metrics are filtered out, but this is currently not the case, see ExternalMetrics.setExtraMetrics
@Test
public void extra_metrics_packets_containing_whitelisted_metrics_are_added() {
- metricsManager.setExtraMetrics(ImmutableList.of(
+ metricsManager.setExtraMetrics(List.of(
new MetricsPacket.Builder(toServiceId("foo"))
- .putMetrics(ImmutableList.of(new Metric(WHITELISTED_METRIC_ID, 0)))));
+ .putMetrics(List.of(new Metric(WHITELISTED_METRIC_ID, 0)))));
List<MetricsPacket> packets = metricsManager.getMetrics(testServices, Instant.EPOCH);
assertEquals(3, packets.size());
@@ -150,9 +148,9 @@ public class MetricsManagerTest {
@Test
public void extra_metrics_packets_without_whitelisted_metrics_are_not_added() {
- metricsManager.setExtraMetrics(ImmutableList.of(
+ metricsManager.setExtraMetrics(List.of(
new MetricsPacket.Builder(toServiceId("foo"))
- .putMetrics(ImmutableList.of(new Metric(toMetricId("not-whitelisted"), 0)))));
+ .putMetrics(List.of(new Metric(toMetricId("not-whitelisted"), 0)))));
List<MetricsPacket> packets = metricsManager.getMetrics(testServices, Instant.EPOCH);
assertEquals(2, packets.size());
@@ -161,9 +159,9 @@ public class MetricsManagerTest {
@Test
public void application_from_extra_metrics_packets_is_used_as_service_in_result_packets() {
final ServiceId serviceId = toServiceId("custom-service");
- metricsManager.setExtraMetrics(ImmutableList.of(
+ metricsManager.setExtraMetrics(List.of(
new MetricsPacket.Builder(serviceId)
- .putMetrics(ImmutableList.of(new Metric(WHITELISTED_METRIC_ID, 0)))));
+ .putMetrics(List.of(new Metric(WHITELISTED_METRIC_ID, 0)))));
List<MetricsPacket> packets = metricsManager.getMetrics(testServices, Instant.EPOCH);
MetricsPacket extraPacket = null;
@@ -175,9 +173,9 @@ public class MetricsManagerTest {
@Test
public void extra_dimensions_are_added_to_metrics_packets_that_do_not_have_those_dimensions() {
- metricsManager.setExtraMetrics(ImmutableList.of(
+ metricsManager.setExtraMetrics(List.of(
new MetricsPacket.Builder(toServiceId("foo"))
- .putMetrics(ImmutableList.of(new Metric(WHITELISTED_METRIC_ID, 0)))
+ .putMetrics(List.of(new Metric(WHITELISTED_METRIC_ID, 0)))
.putDimension(ROLE_DIMENSION, "role from extraMetrics")));
List<MetricsPacket> packets = metricsManager.getMetrics(testServices, Instant.EPOCH);
@@ -188,9 +186,9 @@ public class MetricsManagerTest {
@Test
public void extra_dimensions_do_not_overwrite_existing_dimension_values() {
- metricsManager.setExtraMetrics(ImmutableList.of(
+ metricsManager.setExtraMetrics(List.of(
new MetricsPacket.Builder(toServiceId("foo"))
- .putMetrics(ImmutableList.of(new Metric(WHITELISTED_METRIC_ID, 0)))
+ .putMetrics(List.of(new Metric(WHITELISTED_METRIC_ID, 0)))
.putDimension(METRIC_TYPE_DIMENSION_ID, "from extraMetrics")));
List<MetricsPacket> packets = metricsManager.getMetrics(testServices, Instant.EPOCH);
diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/HttpHandlerTestBase.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/HttpHandlerTestBase.java
index dd19970efa7..4f9634a061a 100644
--- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/HttpHandlerTestBase.java
+++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/HttpHandlerTestBase.java
@@ -17,7 +17,6 @@ import ai.vespa.metricsproxy.service.DownService;
import ai.vespa.metricsproxy.service.DummyService;
import ai.vespa.metricsproxy.service.VespaService;
import ai.vespa.metricsproxy.service.VespaServices;
-import com.google.common.collect.ImmutableList;
import com.yahoo.container.jdisc.RequestHandlerTestDriver;
import java.time.Instant;
@@ -33,10 +32,9 @@ import static ai.vespa.metricsproxy.service.DummyService.METRIC_1;
*
* @author gjoranv
*/
-@SuppressWarnings("UnstableApiUsage")
public class HttpHandlerTestBase {
- protected static final List<VespaService> testServices = ImmutableList.of(
+ protected static final List<VespaService> testServices = List.of(
new DummyService(0, ""),
new DummyService(1, ""),
new DownService(HealthMetric.getDown("No response")));
@@ -55,10 +53,10 @@ public class HttpHandlerTestBase {
protected static MetricsManager getMetricsManager() {
MetricsManager metricsManager = TestUtil.createMetricsManager(vespaServices, getMetricsConsumers(), getApplicationDimensions(), getNodeDimensions());
- metricsManager.setExtraMetrics(ImmutableList.of(
+ metricsManager.setExtraMetrics(List.of(
new MetricsPacket.Builder(VESPA_NODE_SERVICE_ID)
.timestamp(Instant.now().getEpochSecond())
- .putMetrics(ImmutableList.of(new Metric(MetricId.toMetricId(CPU_METRIC), 12.345)))));
+ .putMetrics(List.of(new Metric(MetricId.toMetricId(CPU_METRIC), 12.345)))));
return metricsManager;
}
diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/ExternalMetricsTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/ExternalMetricsTest.java
index 581367878ca..4e79c11678c 100644
--- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/ExternalMetricsTest.java
+++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/ExternalMetricsTest.java
@@ -6,7 +6,6 @@ import ai.vespa.metricsproxy.core.MetricsConsumers;
import ai.vespa.metricsproxy.metric.model.ConsumerId;
import ai.vespa.metricsproxy.metric.model.MetricsPacket;
import ai.vespa.metricsproxy.metric.model.ServiceId;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import java.util.List;
@@ -29,7 +28,7 @@ public class ExternalMetricsTest {
MetricsConsumers noConsumers = new MetricsConsumers(new ConsumersConfig.Builder().build());
ExternalMetrics externalMetrics = new ExternalMetrics(noConsumers);
- externalMetrics.setExtraMetrics(ImmutableList.of(
+ externalMetrics.setExtraMetrics(List.of(
new MetricsPacket.Builder(toServiceId("foo"))));
List<MetricsPacket.Builder> packets = externalMetrics.getMetrics();
@@ -42,7 +41,7 @@ public class ExternalMetricsTest {
MetricsConsumers noConsumers = new MetricsConsumers(new ConsumersConfig.Builder().build());
ExternalMetrics externalMetrics = new ExternalMetrics(noConsumers);
- externalMetrics.setExtraMetrics(ImmutableList.of(
+ externalMetrics.setExtraMetrics(List.of(
new MetricsPacket.Builder(SERVICE_ID)));
List<MetricsPacket.Builder> packets = externalMetrics.getMetrics();
@@ -59,7 +58,7 @@ public class ExternalMetricsTest {
MetricsConsumers consumers = new MetricsConsumers(consumersConfig);
ExternalMetrics externalMetrics = new ExternalMetrics(consumers);
- externalMetrics.setExtraMetrics(ImmutableList.of(
+ externalMetrics.setExtraMetrics(List.of(
new MetricsPacket.Builder(toServiceId("foo"))));
List<MetricsPacket.Builder> packets = externalMetrics.getMetrics();
diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/MetricsPacketTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/MetricsPacketTest.java
index 4dcdb45feee..57029ff4aff 100644
--- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/MetricsPacketTest.java
+++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/MetricsPacketTest.java
@@ -2,18 +2,15 @@
package ai.vespa.metricsproxy.metric.model;
import ai.vespa.metricsproxy.metric.Metric;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
import org.junit.Test;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import static ai.vespa.metricsproxy.metric.model.ConsumerId.toConsumerId;
import static ai.vespa.metricsproxy.metric.model.MetricId.toMetricId;
import static ai.vespa.metricsproxy.metric.model.ServiceId.toServiceId;
-import static java.util.Collections.singleton;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -45,8 +42,8 @@ public class MetricsPacketTest {
MetricsPacket packet = new MetricsPacket.Builder(toServiceId("foo"))
.statusCode(0)
.statusMessage("")
- .addConsumers(singleton(DUPLICATE_CONSUMER))
- .addConsumers(singleton(DUPLICATE_CONSUMER))
+ .addConsumers(Set.of(DUPLICATE_CONSUMER))
+ .addConsumers(Set.of(DUPLICATE_CONSUMER))
.build();
assertEquals(1, packet.consumers().size());
}
@@ -57,17 +54,17 @@ public class MetricsPacketTest {
var builder = new MetricsPacket.Builder(toServiceId("foo"))
.statusCode(0)
.statusMessage("")
- .addConsumers(singleton(consumer));
+ .addConsumers(Set.of(consumer));
assertTrue(builder.hasConsumer(consumer));
}
@Test
public void builder_can_retain_subset_of_metrics() {
MetricsPacket packet = new MetricsPacket.Builder(toServiceId("foo"))
- .putMetrics(ImmutableList.of(
+ .putMetrics(List.of(
new Metric(toMetricId("remove"), 1),
new Metric(toMetricId("keep"), 2)))
- .retainMetrics(ImmutableSet.of(toMetricId("keep"), toMetricId("non-existent")))
+ .retainMetrics(Set.of(toMetricId("keep"), toMetricId("non-existent")))
.build();
assertFalse("should not contain 'remove'", packet.metrics().containsKey(toMetricId("remove")));
@@ -86,14 +83,14 @@ public class MetricsPacketTest {
MetricId THREE_ID = toMetricId(THREE);
MetricId NON_EXISTENT_ID = toMetricId(NON_EXISTENT);
- Map<MetricId, List<MetricId>> outputNamesById = ImmutableMap.of(
- ONE_ID, ImmutableList.of(ONE_ID),
- TWO_ID, ImmutableList.of(TWO_ID, toMetricId("dos")),
- THREE_ID, ImmutableList.of(toMetricId("3")),
- NON_EXISTENT_ID, ImmutableList.of(NON_EXISTENT_ID));
+ Map<MetricId, List<MetricId>> outputNamesById = Map.of(
+ ONE_ID, List.of(ONE_ID),
+ TWO_ID, List.of(TWO_ID, toMetricId("dos")),
+ THREE_ID, List.of(toMetricId("3")),
+ NON_EXISTENT_ID, List.of(NON_EXISTENT_ID));
MetricsPacket packet = new MetricsPacket.Builder(toServiceId("foo"))
- .putMetrics(ImmutableList.of(
+ .putMetrics(List.of(
new Metric(ONE_ID, 1),
new Metric(TWO_ID, 2),
new Metric(THREE_ID, 3)))
diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/VespaServicesTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/VespaServicesTest.java
index dda8af8559b..f7bfdb0e76f 100644
--- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/VespaServicesTest.java
+++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/VespaServicesTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metricsproxy.service;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import java.util.List;
@@ -18,7 +17,7 @@ public class VespaServicesTest {
@Test
public void services_can_be_retrieved_from_monitoring_name() {
- List<VespaService> dummyServices = ImmutableList.of(
+ List<VespaService> dummyServices = List.of(
new DummyService(0, "dummy/id/0"),
new DummyService(1, "dummy/id/1"));
VespaServices services = new VespaServices(dummyServices);
@@ -28,7 +27,7 @@ public class VespaServicesTest {
@Test
public void all_services_can_be_retrieved_by_using_special_name() {
- List<VespaService> dummyServices = ImmutableList.of(
+ List<VespaService> dummyServices = List.of(
new DummyService(0, "dummy/id/0"));
VespaServices services = new VespaServices(dummyServices);
diff --git a/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java b/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java
index 65515deee51..1ecec4108a3 100644
--- a/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java
+++ b/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java
@@ -2,13 +2,10 @@
package ai.vespa.models.evaluation;
import com.yahoo.api.annotations.Beta;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.yahoo.searchlib.rankingexpression.ExpressionFunction;
import com.yahoo.searchlib.rankingexpression.evaluation.ContextIndex;
-import com.yahoo.searchlib.rankingexpression.evaluation.DoubleValue;
import com.yahoo.searchlib.rankingexpression.evaluation.ExpressionOptimizer;
-import com.yahoo.searchlib.rankingexpression.evaluation.Value;
import com.yahoo.tensor.TensorType;
import java.util.Arrays;
@@ -32,10 +29,10 @@ public class Model {
private final String name;
/** Free functions */
- private final ImmutableList<ExpressionFunction> functions;
+ private final List<ExpressionFunction> functions;
/** The subset of the free functions which are public (additional non-public methods are generated during import) */
- private final ImmutableList<ExpressionFunction> publicFunctions;
+ private final List<ExpressionFunction> publicFunctions;
/** Instances of each usage of the above function, where variables (if any) are replaced by their bindings */
private final ImmutableMap<FunctionReference, ExpressionFunction> referencedFunctions;
@@ -67,7 +64,7 @@ public class Model {
try {
LazyArrayContext context = new LazyArrayContext(function.getValue(), referencedFunctions, constants, onnxModels, this);
contextBuilder.put(function.getValue().getName(), context);
- if ( ! function.getValue().returnType().isPresent()) {
+ if (function.getValue().returnType().isEmpty()) {
functions.put(function.getKey(), function.getValue().withReturnType(TensorType.empty));
}
@@ -96,10 +93,9 @@ public class Model {
}
}
this.contextPrototypes = contextBuilder.build();
- this.functions = ImmutableList.copyOf(functions.values());
- this.publicFunctions = ImmutableList.copyOf(functions.values().stream()
- .filter(f -> ! f.getName().startsWith(INTERMEDIATE_OPERATION_FUNCTION_PREFIX))
- .collect(Collectors.toList()));
+ this.functions = List.copyOf(functions.values());
+ this.publicFunctions = functions.values().stream()
+ .filter(f -> !f.getName().startsWith(INTERMEDIATE_OPERATION_FUNCTION_PREFIX)).toList();
// Optimize functions
ImmutableMap.Builder<FunctionReference, ExpressionFunction> functionsBuilder = new ImmutableMap.Builder<>();
@@ -129,20 +125,11 @@ public class Model {
}
/** Returns the given function, or throws a IllegalArgumentException if it does not exist */
- ExpressionFunction requireFunction(String name) {
- ExpressionFunction function = function(name);
- if (function == null)
- throw new IllegalArgumentException("No function named '" + name + "' in " + this + ". Available functions: " +
- functions.stream().map(f -> f.getName()).collect(Collectors.joining(", ")));
- return function;
- }
-
- /** Returns the given function, or throws a IllegalArgumentException if it does not exist */
private LazyArrayContext requireContextPrototype(String name) {
LazyArrayContext context = contextPrototypes.get(name);
if (context == null) // Implies function is not present
throw new IllegalArgumentException("No function named '" + name + "' in " + this + ". Available functions: " +
- functions.stream().map(f -> f.getName()).collect(Collectors.joining(", ")));
+ functions.stream().map(ExpressionFunction::getName).collect(Collectors.joining(", ")));
return context;
}
@@ -234,7 +221,7 @@ public class Model {
private void throwUndeterminedFunction(String message) {
throw new IllegalArgumentException(message + ". Available functions: " +
- functions.stream().map(f -> f.getName()).collect(Collectors.joining(", ")));
+ functions.stream().map(ExpressionFunction::getName).collect(Collectors.joining(", ")));
}
@Override
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepository.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepository.java
index a4a047b524c..76ee3a52d64 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepository.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepository.java
@@ -195,7 +195,13 @@ public class RealNodeRepository implements NodeRepository {
nodeResources.bandwidthGbps,
diskSpeedFromString(nodeResources.diskSpeed),
storageTypeFromString(nodeResources.storageType),
- architectureFromString(nodeResources.architecture));
+ architectureFromString(nodeResources.architecture),
+ gpuResourcesFrom(nodeResources));
+ }
+
+ private static NodeResources.GpuResources gpuResourcesFrom(NodeRepositoryNode.NodeResources nodeResources) {
+ if (nodeResources.gpuCount == null || nodeResources.gpuMemoryGb == null) return NodeResources.GpuResources.zero();
+ return new NodeResources.GpuResources(nodeResources.gpuCount, nodeResources.gpuMemoryGb);
}
private static NodeResources.DiskSpeed diskSpeedFromString(String diskSpeed) {
@@ -233,7 +239,6 @@ public class RealNodeRepository implements NodeRepository {
case fast -> "fast";
case slow -> "slow";
case any -> "any";
- default -> throw new IllegalArgumentException("Unknown disk speed '" + diskSpeed.name() + "'");
};
}
@@ -242,7 +247,6 @@ public class RealNodeRepository implements NodeRepository {
case remote -> "remote";
case local -> "local";
case any -> "any";
- default -> throw new IllegalArgumentException("Unknown storage type '" + storageType.name() + "'");
};
}
@@ -251,7 +255,6 @@ public class RealNodeRepository implements NodeRepository {
case arm64 -> "arm64";
case x86_64 -> "x86_64";
case any -> "any";
- default -> throw new IllegalArgumentException("Unknown architecture '" + architecture.name() + "'");
};
}
@@ -274,6 +277,10 @@ public class RealNodeRepository implements NodeRepository {
node.resources.diskSpeed = toString(resources.diskSpeed());
node.resources.storageType = toString(resources.storageType());
node.resources.architecture = toString(resources.architecture());
+ if (!resources.gpuResources().isZero()) {
+ node.resources.gpuCount = resources.gpuResources().count();
+ node.resources.gpuMemoryGb = resources.gpuResources().memoryGb();
+ }
});
node.type = addNode.nodeType.name();
node.ipAddresses = addNode.ipAddresses;
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/bindings/NodeRepositoryNode.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/bindings/NodeRepositoryNode.java
index 956795e09e9..434acca767a 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/bindings/NodeRepositoryNode.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/bindings/NodeRepositoryNode.java
@@ -197,18 +197,24 @@ public class NodeRepositoryNode {
public String storageType;
@JsonProperty
public String architecture;
+ @JsonProperty
+ public Integer gpuCount;
+ @JsonProperty
+ public Double gpuMemoryGb;
@Override
public String toString() {
return "NodeResources{" +
- "vcpu=" + vcpu +
- ", memoryGb=" + memoryGb +
- ", diskGb=" + diskGb +
- ", bandwidthGbps=" + bandwidthGbps +
- ", diskSpeed='" + diskSpeed + '\'' +
- ", storageType='" + storageType + '\'' +
- ", architecture='" + architecture + '\'' +
- '}';
+ "vcpu=" + vcpu +
+ ", memoryGb=" + memoryGb +
+ ", diskGb=" + diskGb +
+ ", bandwidthGbps=" + bandwidthGbps +
+ ", diskSpeed='" + diskSpeed + '\'' +
+ ", storageType='" + storageType + '\'' +
+ ", architecture='" + architecture + '\'' +
+ ", gpuCount=" + gpuCount +
+ ", gpuMemoryGb=" + gpuMemoryGb +
+ '}';
}
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
index 7e4850c2d16..a4aa4daa790 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
@@ -123,6 +123,7 @@ public final class Node implements Nodelike {
if (!ipConfig.pool().ipSet().isEmpty()) throw new IllegalArgumentException("A child node cannot have an IP address pool");
if (modelName.isPresent()) throw new IllegalArgumentException("A child node cannot have model name set");
if (switchHostname.isPresent()) throw new IllegalArgumentException("A child node cannot have switch hostname set");
+ if (status.wantToRebuild()) throw new IllegalArgumentException("A child node cannot be rebuilt");
}
if (type != NodeType.host && reservedTo.isPresent())
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java
index 1e2ecb98a42..b98c9c97437 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java
@@ -659,7 +659,7 @@ public class Nodes {
if (wantToRetire) { // Apply recursively if we're retiring
List<Node> updatedNodes = performOn(list().childrenOf(host), (node, nodeLock) -> {
- Node newNode = node.withWantToRetire(wantToRetire, wantToDeprovision, wantToRebuild, agent, instant);
+ Node newNode = node.withWantToRetire(wantToRetire, wantToDeprovision, false, agent, instant);
return write(newNode, nodeLock);
});
result.addAll(updatedNodes);
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java
index 1e745b61eaa..5fe9eef7e73 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.hosted.provision.persistence;
import com.google.common.cache.AbstractCache;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.provision.HostName;
import com.yahoo.path.Path;
import com.yahoo.transaction.NestedTransaction;
@@ -155,7 +154,7 @@ public class CuratorDatabase {
@Override
public List<String> getChildren(Path path) {
- return get(children, path, () -> ImmutableList.copyOf(curator.getChildren(path)));
+ return get(children, path, () -> List.copyOf(curator.getChildren(path)));
}
@Override
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java
index d7cd42f5c96..7947fe9f021 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.hosted.provision.provisioning;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationTransaction;
-import com.yahoo.config.provision.CloudAccount;
import com.yahoo.config.provision.ClusterMembership;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.Flavor;
@@ -89,8 +88,7 @@ class Activator {
NodeList activeToRemove = oldActive.matching(node -> ! hostnames.contains(node.hostname()));
remove(activeToRemove, transaction); // TODO: Pass activation time in this call and next line
- // TODO (freva): Replace .mapToList(...) with .asList() after 8.80
- nodeRepository.nodes().activate(newActive.mapToList(node -> fixCloudAccount(node, allNodes)), transaction.nested()); // activate also continued active to update node state
+ nodeRepository.nodes().activate(newActive.asList(), transaction.nested()); // activate also continued active to update node state
rememberResourceChange(transaction, generation, activationTime,
oldActive.not().retired(),
@@ -250,14 +248,4 @@ class Activator {
return null;
}
- private Node fixCloudAccount(Node node, NodeList allNodes) {
- // Existing nodes do not have cloudAccount set, copy the one from parent
- CloudAccount cloudAccount = allNodes.parentOf(node).map(Node::cloudAccount).orElseGet(node::cloudAccount);
- return new Node(node.id(), node.ipConfig(), node.hostname(),
- node.parentHostname(), node.flavor(), node.status(), node.state(), node.allocation(), node.history(),
- node.type(), node.reports(), node.modelName(), node.reservedTo(),
- node.exclusiveToApplicationId(), node.exclusiveToClusterType(), node.switchHostname(),
- node.trustedCertificates(), cloudAccount, node.wireguardPubKey());
- }
-
}
diff --git a/pom.xml b/pom.xml
index d0277bcce69..6b91704c4e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -136,7 +136,6 @@
<module>vespa-maven-plugin</module>
<module>vespa-osgi-testrunner</module>
<module>vespa-testrunner-components</module>
- <module>vespa_feed_perf</module>
<module>vespa-3party-bundles</module>
<module>vespajlib</module>
<module>vespalog</module>
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
index 6fa1bdcf072..b145192eb3a 100644
--- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
+++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
@@ -1271,7 +1271,6 @@ TEST_F("NN blueprint handles weak filter (pre-filtering)", NearestNeighborBluepr
filter->setBit(5);
filter->setBit(7);
filter->setBit(9);
- filter->setBit(11);
filter->invalidateCachedCount();
auto weak_filter = GlobalFilter::create(std::move(filter));
bp->set_global_filter(*weak_filter, 0.6);
diff --git a/vespa_feed_perf/.gitignore b/vespa_feed_perf/.gitignore
deleted file mode 100644
index 12251442258..00000000000
--- a/vespa_feed_perf/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/target
-/pom.xml.build
diff --git a/vespa_feed_perf/CMakeLists.txt b/vespa_feed_perf/CMakeLists.txt
deleted file mode 100644
index e7339795fcd..00000000000
--- a/vespa_feed_perf/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-install_jar(vespa_feed_perf-jar-with-dependencies.jar)
-
-vespa_install_script(src/main/sh/vespa-feed-perf vespa-feed-perf bin)
diff --git a/vespa_feed_perf/OWNERS b/vespa_feed_perf/OWNERS
deleted file mode 100644
index 9dc0c2d970d..00000000000
--- a/vespa_feed_perf/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-baldersheim
diff --git a/vespa_feed_perf/README b/vespa_feed_perf/README
deleted file mode 100644
index cbe56b24496..00000000000
--- a/vespa_feed_perf/README
+++ /dev/null
@@ -1 +0,0 @@
-Feeder using MessageBus for testing.
diff --git a/vespa_feed_perf/pom.xml b/vespa_feed_perf/pom.xml
deleted file mode 100644
index a6d43039e58..00000000000
--- a/vespa_feed_perf/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <!-- This module is used in 4 tests:
- interpolated_lookup.rb, match_phase_degradation_test.rb reportcoverage.rb slow_query.rb
- TODO: Remove usage and remove this module -->
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>parent</artifactId>
- <version>8-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
- <artifactId>vespa_feed_perf</artifactId>
- <version>8-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <dependencies>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>documentapi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>messagebus</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <resources>
- <resource>
- <directory>src/test/resources</directory>
- <filtering>false</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <configuration>
- <finalName>${project.artifactId}-jar-with-dependencies</finalName>
- <createDependencyReducedPom>false</createDependencyReducedPom>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>com.yahoo.vespa.feed.perf.SimpleFeeder</mainClass>
- </transformer>
- </transformers>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/vespaclient-java/CMakeLists.txt b/vespaclient-java/CMakeLists.txt
index 242743a06e7..2af1bbe55cd 100644
--- a/vespaclient-java/CMakeLists.txt
+++ b/vespaclient-java/CMakeLists.txt
@@ -11,3 +11,4 @@ vespa_install_script(src/main/sh/vespa-feeder.sh vespa-feeder bin)
vespa_install_script(src/main/sh/vespa-get.sh vespa-get bin)
vespa_install_script(src/main/sh/vespa-visit.sh vespa-visit bin)
vespa_install_script(src/main/sh/vespa-visit-target.sh vespa-visit-target bin)
+vespa_install_script(src/main/sh/vespa-feed-perf vespa-feed-perf bin)
diff --git a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java b/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java
index 0ecc4198e46..0ecc4198e46 100644
--- a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java
diff --git a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java b/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java
index c40e2c21561..c40e2c21561 100644
--- a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java
diff --git a/vespa_feed_perf/src/main/sh/vespa-feed-perf b/vespaclient-java/src/main/sh/vespa-feed-perf
index f8d94df3929..ecc05378751 100755
--- a/vespa_feed_perf/src/main/sh/vespa-feed-perf
+++ b/vespaclient-java/src/main/sh/vespa-feed-perf
@@ -77,4 +77,9 @@ export ROOT
# END environment bootstrap section
-exec java -XX:+UseParallelGC -XX:ParallelGCThreads=4 -jar ${VESPA_HOME}/lib/jars/vespa_feed_perf-jar-with-dependencies.jar "$@"
+export VESPA_LOG_TARGET=file:/dev/null
+export MALLOC_ARENA_MAX=1 # Does not need fast allocation
+java \
+-Djava.library.path=${VESPA_HOME}/libexec64/native:${VESPA_HOME}/lib64 \
+-XX:+UseParallelGC -XX:ParallelGCThreads=4 $(getJavaOptionsIPV46) \
+-cp ${VESPA_HOME}/lib/jars/vespaclient-java-jar-with-dependencies.jar com.yahoo.vespa.feed.perf.SimpleFeeder "$@"
diff --git a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java b/vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java
index fbb38083aad..a188cf3ce5b 100644
--- a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java
@@ -3,23 +3,22 @@ package com.yahoo.vespa.feed.perf;
import com.yahoo.messagebus.routing.Route;
import org.apache.commons.cli.ParseException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Simon Thoresen Hult
diff --git a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/SimpleFeederTest.java b/vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/SimpleFeederTest.java
index 5380796086a..50030d2bc59 100644
--- a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/SimpleFeederTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/SimpleFeederTest.java
@@ -13,7 +13,7 @@ import com.yahoo.messagebus.MessageHandler;
import com.yahoo.messagebus.Reply;
import com.yahoo.messagebus.StaticThrottlePolicy;
import com.yahoo.messagebus.ThrottlePolicy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -22,12 +22,13 @@ import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
+import java.util.List;
import java.util.regex.Pattern;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
/**
* @author Simon Thoresen Hult
@@ -289,8 +290,8 @@ public class SimpleFeederTest {
private static void assertFeed(FeederParams params, InputStream in, MessageHandler validator, String expectedErr, String expectedOut) throws Throwable {
TestDriver driver = new TestDriver(params, in, validator);
driver.run();
- assertMatches(expectedErr, new String(driver.err.toByteArray(), StandardCharsets.UTF_8));
- assertMatches(expectedOut, new String(driver.out.toByteArray(), StandardCharsets.UTF_8));
+ assertMatches(expectedErr, driver.err.toString(StandardCharsets.UTF_8));
+ assertMatches(expectedOut, driver.out.toString(StandardCharsets.UTF_8));
assertTrue(driver.close());
}
@@ -314,7 +315,7 @@ public class SimpleFeederTest {
server = new SimpleServer(CONFIG_DIR, validator);
feeder = new SimpleFeeder(params.setConfigId("dir:" + CONFIG_DIR)
.setStdErr(new PrintStream(err))
- .setInputStreams(Arrays.asList(in))
+ .setInputStreams(List.of(in))
.setStdOut(new PrintStream(out)));
}
diff --git a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/SimpleServer.java b/vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/SimpleServer.java
index a458a59f997..a458a59f997 100644
--- a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/SimpleServer.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespa/feed/perf/SimpleServer.java
diff --git a/vespa_feed_perf/src/test/resources/documentmanager.cfg b/vespaclient-java/src/test/resources/documentmanager.cfg
index 2bd7a3c6080..2bd7a3c6080 100644
--- a/vespa_feed_perf/src/test/resources/documentmanager.cfg
+++ b/vespaclient-java/src/test/resources/documentmanager.cfg
diff --git a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
index b73f50fe00f..d802012e71a 100644
--- a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
+++ b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
@@ -1,9 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.collections;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
@@ -48,21 +45,13 @@ public class ListMap<K, V> {
/** Puts an element into this. Multiple elements at the same position are added to the list at this key */
public void put(K key, V value) {
- List<V> list = map.get(key);
- if (list == null) {
- list = new ArrayList<>();
- map.put(key, list);
- }
+ List<V> list = map.computeIfAbsent(key, k -> new ArrayList<>());
list.add(value);
}
/** Put a key without adding a new value, such that there is an empty list of values if no values are already added */
public void put(K key) {
- List<V> list = map.get(key);
- if (list == null) {
- list = new ArrayList<>();
- map.put(key, list);
- }
+ map.computeIfAbsent(key, k -> new ArrayList<>());
}
/** Put this map in the state where it has just the given value of the given key */
@@ -110,7 +99,7 @@ public class ListMap<K, V> {
*/
public List<V> get(K key) {
List<V> list = map.get(key);
- if (list == null) return ImmutableList.of();;
+ if (list == null) return List.of();;
return list;
}
@@ -137,8 +126,8 @@ public class ListMap<K, V> {
frozen = true;
for (Map.Entry<K,List<V>> entry : map.entrySet())
- entry.setValue(ImmutableList.copyOf(entry.getValue()));
- this.map = ImmutableMap.copyOf(this.map);
+ entry.setValue(List.copyOf(entry.getValue()));
+ this.map = Map.copyOf(this.map);
}
/** Returns whether this allows changes */
diff --git a/vespajlib/src/main/java/com/yahoo/errorhandling/Results.java b/vespajlib/src/main/java/com/yahoo/errorhandling/Results.java
index 89dd44cb9fc..917b7251c15 100644
--- a/vespajlib/src/main/java/com/yahoo/errorhandling/Results.java
+++ b/vespajlib/src/main/java/com/yahoo/errorhandling/Results.java
@@ -1,11 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.errorhandling;
-import com.google.common.collect.ImmutableList;
-
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
/**
@@ -17,8 +14,8 @@ public class Results<DATA, ERROR> {
private final List<ERROR> errors;
public Results(List<DATA> data, List<ERROR> errors) {
- this.data = ImmutableList.copyOf(data);
- this.errors = ImmutableList.copyOf(errors);
+ this.data = List.copyOf(data);
+ this.errors = List.copyOf(errors);
}
public boolean hasErrors() {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java
index 50809ab3ff6..996d85b3199 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java
@@ -1,19 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.tensor;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Set;
-import java.util.function.DoubleBinaryOperator;
/**
* An indexed (dense) tensor.
@@ -202,7 +199,7 @@ public abstract class IndexedTensor implements Tensor {
@Override
public Map<TensorAddress, Double> cells() {
if (dimensionSizes.dimensions() == 0)
- return Collections.singletonMap(TensorAddress.of(), get(0));
+ return Map.of(TensorAddress.of(), get(0));
ImmutableMap.Builder<TensorAddress, Double> builder = new ImmutableMap.Builder<>();
Indexes indexes = Indexes.of(dimensionSizes, dimensionSizes, size());
@@ -574,7 +571,7 @@ public abstract class IndexedTensor implements Tensor {
throw new IllegalArgumentException("Wrong number of indexes (" + indexes.length + ") for " + type);
if (indexes.length == 0) {
- firstDimension = Collections.singletonList(value);
+ firstDimension = List.of(value);
return this;
}
@@ -767,7 +764,7 @@ public abstract class IndexedTensor implements Tensor {
private final static class LazyCell extends Tensor.Cell {
private double value;
- private Indexes indexes;
+ private final Indexes indexes;
private LazyCell(Indexes indexes, Double value) {
super(null, value);
@@ -919,10 +916,9 @@ public abstract class IndexedTensor implements Tensor {
/** Returns an immutable list containing a copy of the indexes in this */
public List<Long> toList() {
- ImmutableList.Builder<Long> builder = new ImmutableList.Builder<>();
- for (long index : indexes)
- builder.add(index);
- return builder.build();
+ ArrayList<Long> list = new ArrayList<>(indexes.length);
+ for(long index : indexes) { list.add(index); }
+ return List.copyOf(list);
}
@Override
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java
index e7690876434..fed9f7017ed 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/MixedTensor.java
@@ -11,7 +11,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.function.DoubleBinaryOperator;
import java.util.stream.Collectors;
/**
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmax.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmax.java
index d2762ad762d..2ee3d7dab60 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmax.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmax.java
@@ -1,10 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.evaluation.Name;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -17,21 +15,21 @@ public class Argmax<NAMETYPE extends Name> extends CompositeTensorFunction<NAMET
private final List<String> dimensions;
public Argmax(TensorFunction<NAMETYPE> argument) {
- this(argument, Collections.emptyList());
+ this(argument, List.of());
}
public Argmax(TensorFunction<NAMETYPE> argument, String dimension) {
- this(argument, Collections.singletonList(dimension));
+ this(argument, List.of(dimension));
}
public Argmax(TensorFunction<NAMETYPE> argument, List<String> dimensions) {
Objects.requireNonNull(dimensions, "The dimensions cannot be null");
this.argument = argument;
- this.dimensions = ImmutableList.copyOf(dimensions);
+ this.dimensions = List.copyOf(dimensions);
}
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return Collections.singletonList(argument); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argument); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmin.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmin.java
index baedf41bcb8..a1e30c419e3 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmin.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Argmin.java
@@ -1,10 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.evaluation.Name;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -17,21 +15,21 @@ public class Argmin<NAMETYPE extends Name> extends CompositeTensorFunction<NAMET
private final List<String> dimensions;
public Argmin(TensorFunction<NAMETYPE> argument) {
- this(argument, Collections.emptyList());
+ this(argument, List.of());
}
public Argmin(TensorFunction<NAMETYPE> argument, String dimension) {
- this(argument, Collections.singletonList(dimension));
+ this(argument, List.of(dimension));
}
public Argmin(TensorFunction<NAMETYPE> argument, List<String> dimensions) {
Objects.requireNonNull(dimensions, "The dimensions cannot be null");
this.argument = argument;
- this.dimensions = ImmutableList.copyOf(dimensions);
+ this.dimensions = List.copyOf(dimensions);
}
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return Collections.singletonList(argument); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argument); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java
index abf0d89c2b7..2a93acc19e6 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.DimensionSizes;
import com.yahoo.tensor.IndexedTensor;
import com.yahoo.tensor.Tensor;
@@ -46,7 +45,7 @@ public class Concat<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
}
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return ImmutableList.of(argumentA, argumentB); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argumentA, argumentB); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
@@ -362,20 +361,11 @@ public class Concat<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
int b = 0;
for (var how : plan.combineHow) {
switch (how) {
- case left:
- labels[out++] = leftOnly.label(a++);
- break;
- case right:
- labels[out++] = rightOnly.label(b++);
- break;
- case both:
- labels[out++] = match.label(m++);
- break;
- case concat:
- labels[out++] = String.valueOf(concatDimIdx);
- break;
- default:
- throw new IllegalArgumentException("cannot handle: "+how);
+ case left -> labels[out++] = leftOnly.label(a++);
+ case right -> labels[out++] = rightOnly.label(b++);
+ case both -> labels[out++] = match.label(m++);
+ case concat -> labels[out++] = String.valueOf(concatDimIdx);
+ default -> throw new IllegalArgumentException("cannot handle: " + how);
}
}
return TensorAddress.of(labels);
@@ -419,17 +409,10 @@ public class Concat<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
int separateIdx = 0;
for (int i = 0; i < how.handleDims.size(); i++) {
switch (how.handleDims.get(i)) {
- case common:
- commonLabels[commonIdx++] = addr.label(i);
- break;
- case separate:
- separateLabels[separateIdx++] = addr.label(i);
- break;
- case concat:
- ccDimIndex = addr.numericLabel(i);
- break;
- default:
- throw new IllegalArgumentException("cannot handle: "+how.handleDims.get(i));
+ case common -> commonLabels[commonIdx++] = addr.label(i);
+ case separate -> separateLabels[separateIdx++] = addr.label(i);
+ case concat -> ccDimIndex = addr.numericLabel(i);
+ default -> throw new IllegalArgumentException("cannot handle: " + how.handleDims.get(i));
}
}
TensorAddress commonAddr = TensorAddress.of(commonLabels);
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/DynamicTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/DynamicTensor.java
index c402a1bde5b..558b01baa02 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/DynamicTensor.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/DynamicTensor.java
@@ -10,7 +10,6 @@ import com.yahoo.tensor.evaluation.EvaluationContext;
import com.yahoo.tensor.evaluation.Name;
import com.yahoo.tensor.evaluation.TypeContext;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -32,7 +31,7 @@ public abstract class DynamicTensor<NAMETYPE extends Name> extends PrimitiveTens
public TensorType type(TypeContext<NAMETYPE> context) { return type; }
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return Collections.emptyList(); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java
index 1009177761b..61060b700a3 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.yahoo.tensor.DimensionSizes;
import com.yahoo.tensor.IndexedTensor;
@@ -15,7 +14,6 @@ import com.yahoo.tensor.evaluation.Name;
import com.yahoo.tensor.evaluation.TypeContext;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -60,7 +58,7 @@ public class Join<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMETYP
public DoubleBinaryOperator combinator() { return combinator; }
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return ImmutableList.of(argumentA, argumentB); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argumentA, argumentB); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
@@ -345,7 +343,7 @@ public class Join<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMETYP
for (Iterator<Tensor.Cell> cellIterator = b.cellIterator(); cellIterator.hasNext(); ) {
Tensor.Cell bCell = cellIterator.next();
TensorAddress partialCommonAddress = partialCommonAddress(bCell, bIndexesInCommon);
- for (Tensor.Cell aCell : aCellsByCommonAddress.getOrDefault(partialCommonAddress, Collections.emptyList())) {
+ for (Tensor.Cell aCell : aCellsByCommonAddress.getOrDefault(partialCommonAddress, List.of())) {
TensorAddress combinedAddress = joinAddresses(aCell.getKey(), aIndexesInJoined,
bCell.getKey(), bIndexesInJoined, joinedType);
if (combinedAddress == null) continue; // not combinable
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Matmul.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Matmul.java
index 3239ab1a70c..a06053c88a4 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Matmul.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Matmul.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.evaluation.Name;
@@ -27,7 +26,7 @@ public class Matmul<NAMETYPE extends Name> extends CompositeTensorFunction<NAMET
}
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return ImmutableList.of(argument1, argument2); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argument1, argument2); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Merge.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Merge.java
index 2b9dc709e0e..86d3ca50bd7 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Merge.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Merge.java
@@ -1,11 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.tensor.functions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Sets;
-import com.yahoo.tensor.DimensionSizes;
import com.yahoo.tensor.IndexedTensor;
-import com.yahoo.tensor.PartialAddress;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorAddress;
import com.yahoo.tensor.TensorType;
@@ -14,15 +10,10 @@ import com.yahoo.tensor.evaluation.EvaluationContext;
import com.yahoo.tensor.evaluation.Name;
import com.yahoo.tensor.evaluation.TypeContext;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
import java.util.function.DoubleBinaryOperator;
/**
@@ -55,7 +46,7 @@ public class Merge<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMETY
public DoubleBinaryOperator merger() { return merger; }
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return ImmutableList.of(argumentA, argumentB); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argumentA, argumentB); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.java
index 96465de6c0f..83d5187f116 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.IndexedTensor;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorAddress;
@@ -37,12 +36,12 @@ public class Reduce<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
/** Creates a reduce function reducing all dimensions */
public Reduce(TensorFunction<NAMETYPE> argument, Aggregator aggregator) {
- this(argument, aggregator, Collections.emptyList());
+ this(argument, aggregator, List.of());
}
/** Creates a reduce function reducing a single dimension */
public Reduce(TensorFunction<NAMETYPE> argument, Aggregator aggregator, String dimension) {
- this(argument, aggregator, Collections.singletonList(dimension));
+ this(argument, aggregator, List.of(dimension));
}
/**
@@ -57,7 +56,7 @@ public class Reduce<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
public Reduce(TensorFunction<NAMETYPE> argument, Aggregator aggregator, List<String> dimensions) {
this.argument = Objects.requireNonNull(argument, "The argument tensor cannot be null");
this.aggregator = Objects.requireNonNull(aggregator, "The aggregator cannot be null");
- this.dimensions = ImmutableList.copyOf(dimensions);
+ this.dimensions = List.copyOf(dimensions);
}
public static TensorType outputType(TensorType inputType, List<String> reduceDimensions) {
@@ -71,7 +70,7 @@ public class Reduce<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
List<String> dimensions() { return dimensions; }
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return Collections.singletonList(argument); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argument); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
@@ -174,16 +173,16 @@ public class Reduce<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
static abstract class ValueAggregator {
static ValueAggregator ofType(Aggregator aggregator) {
- switch (aggregator) {
- case avg : return new AvgAggregator();
- case count : return new CountAggregator();
- case max : return new MaxAggregator();
- case median : return new MedianAggregator();
- case min : return new MinAggregator();
- case prod : return new ProdAggregator();
- case sum : return new SumAggregator();
- default: throw new UnsupportedOperationException("Aggregator " + aggregator + " is not implemented");
- }
+ return switch (aggregator) {
+ case avg -> new AvgAggregator();
+ case count -> new CountAggregator();
+ case max -> new MaxAggregator();
+ case median -> new MedianAggregator();
+ case min -> new MinAggregator();
+ case prod -> new ProdAggregator();
+ case sum -> new SumAggregator();
+ default -> throw new UnsupportedOperationException("Aggregator " + aggregator + " is not implemented");
+ };
}
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/ReduceJoin.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/ReduceJoin.java
index ccb437ef5a7..1048e5ab10e 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/ReduceJoin.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/ReduceJoin.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.DimensionSizes;
import com.yahoo.tensor.IndexedTensor;
import com.yahoo.tensor.Tensor;
@@ -47,12 +46,12 @@ public class ReduceJoin<NAMETYPE extends Name> extends CompositeTensorFunction<N
this.argumentB = argumentB;
this.combinator = combinator;
this.aggregator = aggregator;
- this.dimensions = ImmutableList.copyOf(dimensions);
+ this.dimensions = List.copyOf(dimensions);
}
@Override
public List<TensorFunction<NAMETYPE>> arguments() {
- return ImmutableList.of(argumentA, argumentB);
+ return List.of(argumentA, argumentB);
}
@Override
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Rename.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Rename.java
index 023e91e424f..8d58cee5e1e 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Rename.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Rename.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorAddress;
import com.yahoo.tensor.TensorType;
@@ -10,7 +9,6 @@ import com.yahoo.tensor.evaluation.EvaluationContext;
import com.yahoo.tensor.evaluation.Name;
import com.yahoo.tensor.evaluation.TypeContext;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -30,7 +28,7 @@ public class Rename<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
private final Map<String, String> fromToMap;
public Rename(TensorFunction<NAMETYPE> argument, String fromDimension, String toDimension) {
- this(argument, ImmutableList.of(fromDimension), ImmutableList.of(toDimension));
+ this(argument, List.of(fromDimension), List.of(toDimension));
}
public Rename(TensorFunction<NAMETYPE> argument, List<String> fromDimensions, List<String> toDimensions) {
@@ -43,8 +41,8 @@ public class Rename<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
throw new IllegalArgumentException("Rename from and to dimensions must be equal, was " +
fromDimensions.size() + " and " + toDimensions.size());
this.argument = argument;
- this.fromDimensions = ImmutableList.copyOf(fromDimensions);
- this.toDimensions = ImmutableList.copyOf(toDimensions);
+ this.fromDimensions = List.copyOf(fromDimensions);
+ this.toDimensions = List.copyOf(toDimensions);
this.fromToMap = fromToMap(fromDimensions, toDimensions);
}
@@ -59,7 +57,7 @@ public class Rename<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET
}
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return Collections.singletonList(argument); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(argument); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/ScalarFunctions.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/ScalarFunctions.java
index 2639e153923..1057ffa9552 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/ScalarFunctions.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/ScalarFunctions.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
-
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
@@ -510,9 +508,9 @@ public class ScalarFunctions {
// Variable-length operators -----------------------------------------------------------------------------
public static class EqualElements implements Function<List<Long>, Double> {
- private final ImmutableList<String> argumentNames;
+ private final List<String> argumentNames;
private EqualElements(List<String> argumentNames) {
- this.argumentNames = ImmutableList.copyOf(argumentNames);
+ this.argumentNames = List.copyOf(argumentNames);
}
@Override
@@ -553,9 +551,9 @@ public class ScalarFunctions {
}
public static class SumElements implements Function<List<Long>, Double> {
- private final ImmutableList<String> argumentNames;
+ private final List<String> argumentNames;
private SumElements(List<String> argumentNames) {
- this.argumentNames = ImmutableList.copyOf(argumentNames);
+ this.argumentNames = List.copyOf(argumentNames);
}
@Override
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Softmax.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Softmax.java
index df8cd6d39cd..0853e1becf6 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Softmax.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Softmax.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.evaluation.Name;
@@ -23,7 +22,7 @@ public class Softmax<NAMETYPE extends Name> extends CompositeTensorFunction<NAME
}
public static TensorType outputType(TensorType inputType, String dimension) {
- return Reduce.outputType(inputType, ImmutableList.of(dimension));
+ return Reduce.outputType(inputType, List.of(dimension));
}
@Override
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/XwPlusB.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/XwPlusB.java
index bd4fc7b8336..499cd31d700 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/XwPlusB.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/XwPlusB.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.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.evaluation.Name;
import java.util.List;
@@ -23,7 +22,7 @@ public class XwPlusB<NAMETYPE extends Name> extends CompositeTensorFunction<NAME
}
@Override
- public List<TensorFunction<NAMETYPE>> arguments() { return ImmutableList.of(x, w, b); }
+ public List<TensorFunction<NAMETYPE>> arguments() { return List.of(x, w, b); }
@Override
public TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments) {
diff --git a/vespajlib/src/main/java/com/yahoo/text/StringUtilities.java b/vespajlib/src/main/java/com/yahoo/text/StringUtilities.java
index fb90fabb964..a177b07256b 100644
--- a/vespajlib/src/main/java/com/yahoo/text/StringUtilities.java
+++ b/vespajlib/src/main/java/com/yahoo/text/StringUtilities.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.text;
-import com.google.common.collect.ImmutableSet;
-
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.io.ByteArrayOutputStream;
import java.util.Set;
@@ -212,12 +210,12 @@ public class StringUtilities {
/** Splits a string on both space and comma */
public static Set<String> split(String s) {
- if (s == null || s.isEmpty()) return Collections.emptySet();
- ImmutableSet.Builder<String> b = new ImmutableSet.Builder<>();
+ if (s == null || s.isEmpty()) return Set.of();
+ Set<String> b = new HashSet<>();
for (String item : s.split("[\\s,]"))
if ( ! item.isEmpty())
b.add(item);
- return b.build();
+ return Set.copyOf(b);
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java b/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java
index a5b2accec48..b8a13525159 100644
--- a/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java
+++ b/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.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.stream;
-import com.google.common.collect.Lists;
import com.yahoo.stream.CustomCollectors.DuplicateKeyException;
import org.junit.Test;
@@ -42,7 +41,7 @@ public class CustomCollectorsTest {
@Test
public void custom_map_collector_throws_exception_upon_duplicate_keys() {
- List<String> duplicates = Lists.newArrayList("same", "same");
+ List<String> duplicates = List.of("same", "same");
try {
duplicates.stream().collect(toCustomMap(Function.identity(), Function.identity(), HashMap::new));
@@ -53,7 +52,7 @@ public class CustomCollectorsTest {
}
private static List<String> numberList() {
- return Lists.newArrayList("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten");
+ return List.of("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten");
}
private static class CustomHashMap<K,V> extends HashMap<K,V> {
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java
index ba814f7ad54..09b989e4380 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.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.tensor;
-import com.google.common.collect.Sets;
import org.junit.Test;
+import java.util.Set;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -34,7 +35,7 @@ public class MappedTensorTestCase {
Tensor tensor = Tensor.Builder.of(type).
cell().label("x", "0").value(1).
cell().label("x", "1").value(2).build();
- assertEquals(Sets.newHashSet("x"), tensor.type().dimensionNames());
+ assertEquals(Set.of("x"), tensor.type().dimensionNames());
assertEquals("tensor(x{}):{0:1.0, 1:2.0}", tensor.toString());
}
@@ -44,7 +45,7 @@ public class MappedTensorTestCase {
Tensor tensor = Tensor.Builder.of(type).
cell().label("x", "0").label("y", "0").value(1).
cell().label("x", "1").label("y", "0").value(2).build();
- assertEquals(Sets.newHashSet("x", "y"), tensor.type().dimensionNames());
+ assertEquals(Set.of("x", "y"), tensor.type().dimensionNames());
assertEquals("tensor(x{},y{}):{{x:0,y:0}:1.0, {x:1,y:0}:2.0}", tensor.toString());
}
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java
index a26e56c4468..0b5b761224b 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java
@@ -2,9 +2,10 @@
package com.yahoo.tensor;
-import com.google.common.collect.Sets;
import org.junit.Test;
+import java.util.Set;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -40,7 +41,7 @@ public class MixedTensorTestCase {
cell().label("y", 1).value(2).
// {y:2} should be 0.0 and non NaN since we specify indexed size
build();
- assertEquals(Sets.newHashSet("y"), tensor.type().dimensionNames());
+ assertEquals(Set.of("y"), tensor.type().dimensionNames());
assertEquals("tensor(y[3]):[1.0, 2.0, 0.0]",
tensor.toString());
}
@@ -56,7 +57,7 @@ public class MixedTensorTestCase {
cell().label("x", 1).label("y", 1).value(5).
cell().label("x", 1).label("y", 2).value(6).
build();
- assertEquals(Sets.newHashSet("x", "y"), tensor.type().dimensionNames());
+ assertEquals(Set.of("x", "y"), tensor.type().dimensionNames());
assertEquals("tensor(x[2],y[3]):[[1.0, 2.0, 0.0], [4.0, 5.0, 6.0]]",
tensor.toString());
}
@@ -68,7 +69,7 @@ public class MixedTensorTestCase {
cell().label("x", "0").value(1).
cell().label("x", "1").value(2).
build();
- assertEquals(Sets.newHashSet("x"), tensor.type().dimensionNames());
+ assertEquals(Set.of("x"), tensor.type().dimensionNames());
assertEquals("tensor(x{}):{0:1.0, 1:2.0}",
tensor.toString());
}
@@ -83,7 +84,7 @@ public class MixedTensorTestCase {
cell().label("x", "1").label("y", "1").value(5).
cell().label("x", "1").label("y", "2").value(6).
build();
- assertEquals(Sets.newHashSet("x", "y"), tensor.type().dimensionNames());
+ assertEquals(Set.of("x", "y"), tensor.type().dimensionNames());
assertEquals("tensor(x{},y{}):{{x:0,y:0}:1.0, {x:0,y:1}:2.0, {x:1,y:0}:4.0, {x:1,y:1}:5.0, {x:1,y:2}:6.0}",
tensor.toString());
}
@@ -99,7 +100,7 @@ public class MixedTensorTestCase {
cell().label("x", "2").label("y", 1).value(5).
cell().label("x", "2").label("y", 2).value(6).
build();
- assertEquals(Sets.newHashSet("x", "y"), tensor.type().dimensionNames());
+ assertEquals(Set.of("x", "y"), tensor.type().dimensionNames());
assertEquals("tensor(x{},y[3]):{1:[1.0, 2.0, 0.0], 2:[4.0, 5.0, 6.0]}",
tensor.toString());
}
@@ -121,7 +122,7 @@ public class MixedTensorTestCase {
cell().label("x", "x2").label("y", 2).label("z","z1").value(15).
cell().label("x", "x2").label("y", 2).label("z","z2").value(16).
build();
- assertEquals(Sets.newHashSet("x", "y", "z"), tensor.type().dimensionNames());
+ assertEquals(Set.of("x", "y", "z"), tensor.type().dimensionNames());
assertEquals("tensor(x{},y[3],z{}):{{x:x1,y:0,z:z1}:1.0, {x:x1,y:0,z:z2}:2.0, {x:x1,y:1,z:z1}:3.0, " +
"{x:x1,y:1,z:z2}:4.0, {x:x1,y:2,z:z1}:5.0, {x:x1,y:2,z:z2}:6.0, {x:x2,y:0,z:z1}:11.0, " +
"{x:x2,y:0,z:z2}:12.0, {x:x2,y:1,z:z1}:13.0, {x:x2,y:1,z:z2}:14.0, {x:x2,y:2,z:z1}:15.0, {x:x2,y:2,z:z2}:16.0}",
@@ -149,7 +150,7 @@ public class MixedTensorTestCase {
cell().label("i", "b").label("k","d").label("j",1).label("l",0).value(15).
cell().label("i", "b").label("k","d").label("j",1).label("l",1).value(16).
build();
- assertEquals(Sets.newHashSet("i", "j", "k", "l"), tensor.type().dimensionNames());
+ assertEquals(Set.of("i", "j", "k", "l"), tensor.type().dimensionNames());
assertEquals("tensor(i{},j[2],k{},l[2]):{{i:a,j:0,k:c,l:0}:1.0, {i:a,j:0,k:c,l:1}:2.0, " +
"{i:a,j:0,k:d,l:0}:5.0, {i:a,j:0,k:d,l:1}:6.0, {i:a,j:1,k:c,l:0}:3.0, {i:a,j:1,k:c,l:1}:4.0, " +
"{i:a,j:1,k:d,l:0}:7.0, {i:a,j:1,k:d,l:1}:8.0, {i:b,j:0,k:c,l:0}:9.0, {i:b,j:0,k:c,l:1}:10.0, " +
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java
index 428c8a83b47..5e392a74bf3 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.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.tensor;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.evaluation.MapEvaluationContext;
import com.yahoo.tensor.evaluation.Name;
import com.yahoo.tensor.evaluation.VariableTensor;
@@ -154,7 +153,7 @@ public class TensorTestCase {
Tensor xy = Tensor.from("{{x:0,y:1}:11, {x:1,y:1}:13}");
double nest1 = y.multiply(x.multiply(xy).sum("x")).sum("y").asDouble();
double nest2 = x.multiply(xy).sum("x").multiply(y).sum("y").asDouble();
- double flat = y.multiply(x).multiply(xy).sum(ImmutableList.of("x","y")).asDouble();
+ double flat = y.multiply(x).multiply(xy).sum(List.of("x","y")).asDouble();
assertEquals(nest1, flat, 0.000000001);
assertEquals(nest2, flat, 0.000000001);
}
@@ -176,8 +175,8 @@ public class TensorTestCase {
assertEquals(Tensor.from("{ {x:1,y:1}:0, {x:2,y:1}:1 }"), tensor1.larger(tensor2));
assertEquals(Tensor.from("{ {y:1}:50.0 }"), tensor1.matmul(tensor2, "x"));
assertEquals(Tensor.from("{ {z:1}:3, {z:2}:7 }"), tensor1.rename("x", "z"));
- assertEquals(Tensor.from("{ {y:1,x:1}:8, {x:1,y:2}:12 }"), tensor1.add(tensor2).rename(ImmutableList.of("x", "y"),
- ImmutableList.of("y", "x")));
+ assertEquals(Tensor.from("{ {y:1,x:1}:8, {x:1,y:2}:12 }"), tensor1.add(tensor2).rename(List.of("x", "y"),
+ List.of("y", "x")));
assertEquals(Tensor.from("{ {x:0,y:0}:0, {x:0,y:1}:0, {x:1,y:0}:0, {x:1,y:1}:1, {x:2,y:0}:0, {x:2,y:1}:2, }"),
Tensor.generate(new TensorType.Builder().indexed("x", 3).indexed("y", 2).build(),
(List<Long> indexes) -> (double)indexes.get(0)*indexes.get(1)));
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/functions/MatmulTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/functions/MatmulTestCase.java
index fb4cb659624..1ac796ae9c5 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/functions/MatmulTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/functions/MatmulTestCase.java
@@ -1,11 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.tensor.functions;
-import com.google.common.collect.ImmutableList;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import org.junit.Test;
+import java.util.List;
+
import static org.junit.Assert.assertEquals;
/**
@@ -41,7 +42,7 @@ public class MatmulTestCase {
rb.cell(154,1, 1);
Tensor r = rb.build();
- Tensor result = a.matmul(b.rename(ImmutableList.of("d0","d1"), ImmutableList.of("d1","d2")), "d1")
+ Tensor result = a.matmul(b.rename(List.of("d0","d1"), List.of("d1","d2")), "d1")
.rename("d2","d1");
assertEquals(r, result);
}
@@ -90,7 +91,7 @@ public class MatmulTestCase {
rb.cell(730,1, 1, 1);
Tensor r = rb.build();
- Tensor result = a.matmul(b.rename(ImmutableList.of("d1","d2"), ImmutableList.of("d2","d3")), "d2")
+ Tensor result = a.matmul(b.rename(List.of("d1","d2"), List.of("d2","d3")), "d2")
.rename("d3","d2");
assertEquals(r, result);
}
diff --git a/vespajlib/src/test/java/com/yahoo/text/Benchmark.java b/vespajlib/src/test/java/com/yahoo/text/Benchmark.java
deleted file mode 100644
index 292503f462a..00000000000
--- a/vespajlib/src/test/java/com/yahoo/text/Benchmark.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.text;
-
-// import com.google.common.base.Preconditions;
-// import com.google.inject.Provider;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Simon Thoresen Hult
- */
-class Benchmark {
-
- public static interface Task {
- public long run(CyclicBarrier barrier, int numIterations) throws Exception;
- }
-
-
- public static class TaskProvider {
- final Class<? extends Task> taskClass;
- public Task get() {
- try {
- return taskClass.getDeclaredConstructor().newInstance();
- } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
- public TaskProvider(final Class<? extends Task> taskClass) {
- this.taskClass = taskClass;
- }
- }
-
- private final TaskProvider taskProvider;
- private final int numIterationsPerThread;
- private final int numThreads;
-
- private Benchmark(Builder builder) {
- Objects.requireNonNull(builder.taskProvider, "taskProvider");
-/*
- Preconditions.checkArgument(builder.numIterationsPerThread > 0, "numIterationsPerThread; %s",
- builder.numIterationsPerThread);
- Preconditions.checkArgument(builder.numThreads > 0, "numThreads; %s",
- builder.numThreads);
-*/
- taskProvider = builder.taskProvider;
- numIterationsPerThread = builder.numIterationsPerThread;
- numThreads = builder.numThreads;
- }
-
- public long run() throws Exception {
- final CyclicBarrier barrier = new CyclicBarrier(numThreads);
- List<Callable<Long>> clients = new ArrayList<>(numThreads);
- for (int i = 0; i < numThreads; ++i) {
- final Task task = taskProvider.get();
- clients.add(new Callable<Long>() {
-
- @Override
- public Long call() throws Exception {
- return task.run(barrier, numIterationsPerThread);
- }
- });
- }
- long maxNanosPerClient = 0;
- for (Future<Long> result : Executors.newFixedThreadPool(numThreads).invokeAll(clients)) {
- maxNanosPerClient = Math.max(maxNanosPerClient, result.get());
- }
- return TimeUnit.SECONDS.toNanos(1) * numThreads * numIterationsPerThread / maxNanosPerClient;
- }
-
- public static class Builder {
-
- private TaskProvider taskProvider;
- private int numIterationsPerThread = 1000;
- private int numThreads = 1;
-
- public Builder setNumThreads(int numThreads) {
- this.numThreads = numThreads;
- return this;
- }
-
- public Builder setNumIterationsPerThread(int numIterationsPerThread) {
- this.numIterationsPerThread = numIterationsPerThread;
- return this;
- }
-
- public Builder setTaskClass(final Class<? extends Task> taskClass) {
- return setTaskProvider(new TaskProvider(taskClass));
- }
-
- public Builder setTaskProvider(TaskProvider taskProvider) {
- this.taskProvider = taskProvider;
- return this;
- }
-
- public Benchmark build() {
- return new Benchmark(this);
- }
- }
-
-}
diff --git a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
index 926d19f433f..098eaddacac 100644
--- a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.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.text;
-import com.google.common.collect.ImmutableMap;
import org.junit.Ignore;
import org.junit.Test;
@@ -11,9 +10,9 @@ import java.nio.ByteBuffer;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
+import java.util.Map;
import java.util.function.Function;
-import static com.yahoo.text.Lowercase.toLowerCase;
import static com.yahoo.text.Utf8.calculateBytePositions;
import static com.yahoo.text.Utf8.calculateStringPositions;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -21,7 +20,6 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
@@ -34,62 +32,6 @@ public class Utf8TestCase {
0x34, 0x355, 0x2567, 0xfff, 0xe987, 0x100abc
};
- public void dumpSome() throws java.io.IOException {
- int i = 32;
- int j = 3;
- int cnt = 0;
- while (i < 0x110000) {
- if (i < 0xD800 || i >= 0xE000) ++cnt;
- i += j;
- ++j;
- }
- System.out.println("allocate "+cnt+" array entries");
- int codes[] = new int[cnt];
- i = 32;
- j = 3;
- cnt = 0;
- while (i < 0x110000) {
- if (i < 0xD800 || i >= 0xE000) codes[cnt++] = i;
- i += j;
- ++j;
- }
- assertEquals(cnt, codes.length);
- System.out.println("fill "+cnt+" array entries");
- String str = new String(codes, 0, cnt);
- byte[] arr = Utf8.toBytes(str);
- java.io.FileOutputStream fos = new java.io.FileOutputStream("random-long-utf8.dat");
- fos.write(arr);
- fos.close();
- }
-
- public void dumpMore() throws java.io.IOException {
- java.text.Normalizer.Form form = java.text.Normalizer.Form.NFKC;
-
- java.io.FileOutputStream fos = new java.io.FileOutputStream("lowercase-table.dat");
- for (int i = 0; i < 0x110000; i++) {
- StringBuilder b = new StringBuilder();
- b.appendCodePoint(i);
- String n1 = b.toString();
- String n2 = java.text.Normalizer.normalize(b, form);
- if (n1.equals(n2)) {
- String l = toLowerCase(n1);
- int chars = l.length();
- int codes = l.codePointCount(0, chars);
- if (codes != 1) {
- System.out.println("codepoint "+i+" transformed into "+codes+" codepoints: "+n1+" -> "+l);
- } else {
- int lc = l.codePointAt(0);
- if (lc != i) {
- String o = "lowercase( "+i+" )= "+lc+"\n";
- byte[] arr = Utf8.toBytes(o);
- fos.write(arr);
- }
- }
- }
- }
- fos.close();
- }
-
@Test
public void testSimple() {
String s1 = "test";
@@ -322,7 +264,7 @@ public class Utf8TestCase {
for (char c=0; c < i; c++) {
sb.append(c);
}
- assertTrue(Arrays.equals(Utf8.toBytesStd(sb.toString()), Utf8.toBytes(sb.toString())));
+ assertArrayEquals(Utf8.toBytesStd(sb.toString()), Utf8.toBytes(sb.toString()));
}
}
@@ -340,7 +282,7 @@ public class Utf8TestCase {
byte [] a = Utf8.toBytes(String.valueOf(l));
byte [] b = Utf8.toAsciiBytes(l);
if (!Arrays.equals(a, b)) {
- assertTrue(Arrays.equals(a, b));
+ assertArrayEquals(a, b);
}
}
@@ -348,8 +290,8 @@ public class Utf8TestCase {
public void testBoolean() {
assertEquals("true", String.valueOf(true));
assertEquals("false", String.valueOf(false));
- assertTrue(Arrays.equals(Utf8.toAsciiBytes(true), new Utf8String(String.valueOf(true)).getBytes()));
- assertTrue(Arrays.equals(Utf8.toAsciiBytes(false), new Utf8String(String.valueOf(false)).getBytes()));
+ assertArrayEquals(Utf8.toAsciiBytes(true), new Utf8String(String.valueOf(true)).getBytes());
+ assertArrayEquals(Utf8.toAsciiBytes(false), new Utf8String(String.valueOf(false)).getBytes());
}
@Test
public void testInt()
@@ -358,7 +300,7 @@ public class Utf8TestCase {
byte [] a = Utf8.toBytes(String.valueOf(l));
byte [] b = Utf8.toAsciiBytes(l);
if (!Arrays.equals(a, b)) {
- assertTrue(Arrays.equals(a, b));
+ assertArrayEquals(a, b);
}
}
}
@@ -369,7 +311,7 @@ public class Utf8TestCase {
byte [] a = Utf8.toBytes(String.valueOf(l));
byte [] b = Utf8.toAsciiBytes(l);
if (!Arrays.equals(a, b)) {
- assertTrue(Arrays.equals(a, b));
+ assertArrayEquals(a, b);
}
}
}
@@ -561,7 +503,7 @@ public class Utf8TestCase {
byte[] unicode = "This is just sort of random mix. \u5370\u57df\u60c5\u5831\u53EF\u4EE5\u6709x\u00e9\u00e8".getBytes(StandardCharsets.UTF_8);
int iterations = 100_000; // Use 100_000+ for benchmarking
- ImmutableMap.of("ascii", ascii, "unicode", unicode).forEach((type, b) -> {
+ Map.of("ascii", ascii, "unicode", unicode).forEach((type, b) -> {
long time1 = benchmark(() -> decode(Utf8::toString, b, iterations));
System.out.printf("Utf8::toString of %s string took %d ms\n", type, time1);
long time2 = benchmark(() -> decode((b1) -> new String(b1, StandardCharsets.UTF_8), b, iterations));
@@ -578,7 +520,7 @@ public class Utf8TestCase {
String unicode = "This is just sort of random mix. \u5370\u57df\u60c5\u5831\u53EF\u4EE5\u6709x\u00e9\u00e8";
int iterations = 1_000_000; // Use 1_000_000+ for benchmarking
- ImmutableMap.of("ascii", ascii, "unicode", unicode).forEach((type, s) -> {
+ Map.of("ascii", ascii, "unicode", unicode).forEach((type, s) -> {
long time1 = benchmark(() -> encode(Utf8::toBytes, s, iterations));
System.out.printf("Utf8::toBytes of %s string took %d ms\n", type, time1);
long time2 = benchmark(() -> encode((s1) -> s1.getBytes(StandardCharsets.UTF_8), s, iterations));
diff --git a/vespalib/src/vespa/vespalib/coro/schedule.h b/vespalib/src/vespa/vespalib/coro/schedule.h
index 71a384f356f..fc589d65a43 100644
--- a/vespalib/src/vespa/vespalib/coro/schedule.h
+++ b/vespalib/src/vespa/vespalib/coro/schedule.h
@@ -22,7 +22,7 @@ auto schedule(Executor &executor) {
awaiter(Executor &executor_in)
: executor(executor_in) {}
bool await_ready() const noexcept { return false; }
- void await_suspend(std::coroutine_handle<> handle) {
+ void await_suspend(std::coroutine_handle<> handle) __attribute__((noinline)) {
struct ResumeTask : Executor::Task {
std::coroutine_handle<> handle;
ResumeTask(std::coroutine_handle<> handle_in)
@@ -52,7 +52,7 @@ auto try_schedule(Executor &executor) {
awaiter(Executor &executor_in)
: executor(executor_in), accepted(true) {}
bool await_ready() const noexcept { return false; }
- bool await_suspend(std::coroutine_handle<> handle) {
+ bool await_suspend(std::coroutine_handle<> handle) __attribute__((noinline)) {
struct ResumeTask : Executor::Task {
std::coroutine_handle<> handle;
ResumeTask(std::coroutine_handle<> handle_in)
@@ -66,8 +66,9 @@ auto try_schedule(Executor &executor) {
// with handle.resume() from executor thread before
// await_suspend has returned.
accepted = false;
+ return false;
}
- return accepted;
+ return true;
}
[[nodiscard]] bool await_resume() const noexcept { return accepted; }
};