diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-12-01 09:32:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-01 09:32:05 +0100 |
commit | 1eb22cc4a24973f52b344c3033cff394c724cbe4 (patch) | |
tree | 98fdcb5bed45fc1199400988d45cf6bb47e413f2 | |
parent | 2925f225b34ad7fa3eb515bbddcc8c774e514131 (diff) |
Revert "Revert "- Reduce usage of guava.""
29 files changed, 159 insertions, 225 deletions
diff --git a/clustercontroller-utils/pom.xml b/clustercontroller-utils/pom.xml index c534794ad0a..381a4c88946 100644 --- a/clustercontroller-utils/pom.xml +++ b/clustercontroller-utils/pom.xml @@ -39,11 +39,6 @@ <artifactId>junit-jupiter-engine</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <scope>provided</scope> - </dependency> </dependencies> <build> <plugins> diff --git a/config-application-package/pom.xml b/config-application-package/pom.xml index 3d471f1c94b..41e65f19b79 100644 --- a/config-application-package/pom.xml +++ b/config-application-package/pom.xml @@ -45,11 +45,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>defaults</artifactId> <version>${project.version}</version> diff --git a/config-provisioning/pom.xml b/config-provisioning/pom.xml index b190bca06a5..b447cb792a6 100644 --- a/config-provisioning/pom.xml +++ b/config-provisioning/pom.xml @@ -46,17 +46,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> - <classifier>no_aop</classifier> - </dependency> - <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>testutil</artifactId> <version>${project.version}</version> diff --git a/docproc/pom.xml b/docproc/pom.xml index 325e198c59a..dce6dafafeb 100644 --- a/docproc/pom.xml +++ b/docproc/pom.xml @@ -17,12 +17,6 @@ <dependencies> <!-- PROVIDED scope --> <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - <classifier>no_aop</classifier> - <scope>provided</scope> - </dependency> - <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>component</artifactId> <version>${project.version}</version> diff --git a/documentapi/pom.xml b/documentapi/pom.xml index 9b690f345ae..271a984ea30 100644 --- a/documentapi/pom.xml +++ b/documentapi/pom.xml @@ -27,8 +27,8 @@ <!-- Needed because 'document' uses guava collections, and has guava only in provided scope --> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> + <scope>test</scope> </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> 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 b6f84b979f5..0c3e69141e9 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java @@ -121,14 +121,11 @@ public class FileReferenceCompressor { switch (type) { case compressed: log.log(Level.FINE, () -> "Compressing with compression type " + compressionType); - switch (compressionType) { - case gzip: - return new GZIPOutputStream(new FileOutputStream(outputFile)); - case lz4: - return new LZ4BlockOutputStream(new FileOutputStream(outputFile)); - default: - throw new RuntimeException("Unknown compression type " + compressionType); - } + return switch (compressionType) { + case gzip -> new GZIPOutputStream(new FileOutputStream(outputFile)); + case lz4 -> new LZ4BlockOutputStream(new FileOutputStream(outputFile)); + default -> throw new RuntimeException("Unknown compression type " + compressionType); + }; case file: return new FileOutputStream(outputFile); default: @@ -140,14 +137,11 @@ public class FileReferenceCompressor { switch (type) { case compressed: log.log(Level.FINE, () -> "Decompressing with compression type " + compressionType); - switch (compressionType) { - case gzip: - return new GZIPInputStream(new FileInputStream(inputFile)); - case lz4: - return new LZ4BlockInputStream(new FileInputStream(inputFile)); - default: - throw new RuntimeException("Unknown compression type " + compressionType); - } + return switch (compressionType) { + case gzip -> new GZIPInputStream(new FileInputStream(inputFile)); + case lz4 -> new LZ4BlockInputStream(new FileInputStream(inputFile)); + default -> throw new RuntimeException("Unknown compression type " + compressionType); + }; case file: return new FileInputStream(inputFile); default: diff --git a/model-evaluation/pom.xml b/model-evaluation/pom.xml index caf28199c3d..c0600872666 100644 --- a/model-evaluation/pom.xml +++ b/model-evaluation/pom.xml @@ -74,11 +74,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.lz4</groupId> <artifactId>lz4-java</artifactId> </dependency> diff --git a/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionEvaluator.java b/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionEvaluator.java index 6af33e29e62..1d3da73a509 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionEvaluator.java +++ b/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionEvaluator.java @@ -101,9 +101,11 @@ public class FunctionEvaluator { } public Tensor evaluate() { - for (Map.Entry<String, TensorType> argument : function.argumentTypes().entrySet()) { - checkArgument(argument.getKey(), argument.getValue()); - } + function.argumentTypes().keySet().stream().sorted() + .forEach(name -> { + var type = function.argumentTypes().get(name); + checkArgument(name, type); + }); evaluated = true; evaluateOnnxModels(); return function.getBody().evaluate(context).asTensor(); diff --git a/model-evaluation/src/main/java/ai/vespa/models/evaluation/LazyArrayContext.java b/model-evaluation/src/main/java/ai/vespa/models/evaluation/LazyArrayContext.java index d030108a17a..81325740218 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/evaluation/LazyArrayContext.java +++ b/model-evaluation/src/main/java/ai/vespa/models/evaluation/LazyArrayContext.java @@ -1,8 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.models.evaluation; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; +import com.yahoo.lang.MutableInteger; import com.yahoo.searchlib.rankingexpression.ExpressionFunction; import com.yahoo.searchlib.rankingexpression.Reference; import com.yahoo.searchlib.rankingexpression.evaluation.Context; @@ -14,6 +13,7 @@ import com.yahoo.searchlib.rankingexpression.rule.CompositeNode; import com.yahoo.searchlib.rankingexpression.rule.ConstantNode; import com.yahoo.searchlib.rankingexpression.rule.ExpressionNode; import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode; +import com.yahoo.stream.CustomCollectors; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; /** * An array context supporting functions invocations implemented as lazy values. @@ -151,16 +152,16 @@ public final class LazyArrayContext extends Context implements ContextIndex { private static class IndexedBindings { /** The mapping from variable name to index */ - private final ImmutableMap<String, Integer> nameToIndex; + private final Map<String, Integer> nameToIndex; /** The names which needs to be bound externally when invoking this (i.e not constant or invocation */ - private final ImmutableSet<String> arguments; + private final Set<String> arguments; /** The current values set */ private final Value[] values; /** ONNX models indexed by rank feature that calls them */ - private final ImmutableMap<String, OnnxModel> onnxModels; + private final Map<String, OnnxModel> onnxModels; /** The object instance which encodes "no value is set". The actual value of this is never used. */ private static final Value missing = new DoubleValue(Double.NaN).freeze(); @@ -169,14 +170,14 @@ public final class LazyArrayContext extends Context implements ContextIndex { private Value missingValue = new DoubleValue(Double.NaN).freeze(); - private IndexedBindings(ImmutableMap<String, Integer> nameToIndex, + private IndexedBindings(Map<String, Integer> nameToIndex, Value[] values, - ImmutableSet<String> arguments, - ImmutableMap<String, OnnxModel> onnxModels) { - this.nameToIndex = nameToIndex; + Set<String> arguments, + Map<String, OnnxModel> onnxModels) { + this.nameToIndex = Map.copyOf(nameToIndex); this.values = values; this.arguments = arguments; - this.onnxModels = onnxModels; + this.onnxModels = Map.copyOf(onnxModels); } /** @@ -195,16 +196,14 @@ public final class LazyArrayContext extends Context implements ContextIndex { Map<String, OnnxModel> onnxModelsInUse = new HashMap<>(); extractBindTargets(function.getBody().getRoot(), referencedFunctions, bindTargets, arguments, onnxModels, onnxModelsInUse); - this.onnxModels = ImmutableMap.copyOf(onnxModelsInUse); - this.arguments = ImmutableSet.copyOf(arguments); + this.onnxModels = Map.copyOf(onnxModelsInUse); + this.arguments = Set.copyOf(arguments); values = new Value[bindTargets.size()]; Arrays.fill(values, missing); - int i = 0; - ImmutableMap.Builder<String, Integer> nameToIndexBuilder = new ImmutableMap.Builder<>(); - for (String variable : bindTargets) - nameToIndexBuilder.put(variable, i++); - nameToIndex = nameToIndexBuilder.build(); + MutableInteger nextIndex = new MutableInteger(0); + nameToIndex = Map.copyOf(bindTargets.stream() + .collect(CustomCollectors.toLinkedMap(name -> name, name -> nextIndex.next()))); // 2. Bind the bind targets for (Constant constant : constants) { @@ -252,8 +251,7 @@ public final class LazyArrayContext extends Context implements ContextIndex { bindTargets.add(node.toString()); arguments.add(node.toString()); } - else if (node instanceof CompositeNode) { - CompositeNode cNode = (CompositeNode)node; + else if (node instanceof CompositeNode cNode) { for (ExpressionNode child : cNode.children()) extractBindTargets(child, functions, bindTargets, arguments, onnxModels, onnxModelsInUse); } @@ -291,16 +289,14 @@ public final class LazyArrayContext extends Context implements ContextIndex { } private Optional<String> getArgument(ExpressionNode node) { - if (node instanceof ReferenceNode) { - ReferenceNode reference = (ReferenceNode) node; + if (node instanceof ReferenceNode reference) { if (reference.getArguments().size() > 0) { if (reference.getArguments().expressions().get(0) instanceof ConstantNode) { ExpressionNode constantNode = reference.getArguments().expressions().get(0); return Optional.of(stripQuotes(constantNode.toString())); } - if (reference.getArguments().expressions().get(0) instanceof ReferenceNode) { - ReferenceNode referenceNode = (ReferenceNode) reference.getArguments().expressions().get(0); - return Optional.of(referenceNode.getName()); + if (reference.getArguments().expressions().get(0) instanceof ReferenceNode refNode) { + return Optional.of(refNode.getName()); } } } @@ -316,20 +312,17 @@ public final class LazyArrayContext extends Context implements ContextIndex { } private boolean isFunctionReference(ExpressionNode node) { - if ( ! (node instanceof ReferenceNode)) return false; - ReferenceNode reference = (ReferenceNode)node; + if ( ! (node instanceof ReferenceNode reference)) return false; return reference.getName().equals("rankingExpression") && reference.getArguments().size() == 1; } private boolean isOnnx(ExpressionNode node) { - if ( ! (node instanceof ReferenceNode)) return false; - ReferenceNode reference = (ReferenceNode) node; + if ( ! (node instanceof ReferenceNode reference)) return false; return reference.getName().equals("onnx") || reference.getName().equals("onnxModel"); } private boolean isConstant(ExpressionNode node) { - if ( ! (node instanceof ReferenceNode)) return false; - ReferenceNode reference = (ReferenceNode)node; + if ( ! (node instanceof ReferenceNode reference)) return false; return reference.getName().equals("constant") && reference.getArguments().size() == 1; } 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 1ecec4108a3..ffcfb5e9379 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,15 +2,16 @@ package ai.vespa.models.evaluation; import com.yahoo.api.annotations.Beta; -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.ExpressionOptimizer; +import com.yahoo.stream.CustomCollectors; import com.yahoo.tensor.TensorType; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -35,10 +36,10 @@ public class Model { 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; + private final Map<FunctionReference, ExpressionFunction> referencedFunctions; /** Context prototypes, indexed by function name (as all invocations of the same function share the same context prototype) */ - private final ImmutableMap<String, LazyArrayContext> contextPrototypes; + private final Map<String, LazyArrayContext> contextPrototypes; private final ExpressionOptimizer expressionOptimizer = new ExpressionOptimizer(); @@ -46,9 +47,9 @@ public class Model { public Model(String name, Collection<ExpressionFunction> functions) { this(name, functions.stream().collect(Collectors.toMap(f -> FunctionReference.fromName(f.getName()), f -> f)), - Collections.emptyMap(), - Collections.emptyList(), - Collections.emptyList()); + Map.of(), + List.of(), + List.of()); } Model(String name, @@ -59,7 +60,7 @@ public class Model { this.name = name; // Build context and add missing function arguments (missing because it is legal to omit scalar type arguments) - ImmutableMap.Builder<String, LazyArrayContext> contextBuilder = new ImmutableMap.Builder<>(); + Map<String, LazyArrayContext> contextBuilder = new LinkedHashMap<>(); for (Map.Entry<FunctionReference, ExpressionFunction> function : functions.entrySet()) { try { LazyArrayContext context = new LazyArrayContext(function.getValue(), referencedFunctions, constants, onnxModels, this); @@ -92,19 +93,14 @@ public class Model { throw new IllegalArgumentException("Could not prepare an evaluation context for " + function, e); } } - this.contextPrototypes = contextBuilder.build(); + this.contextPrototypes = Map.copyOf(contextBuilder); 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<>(); - for (Map.Entry<FunctionReference, ExpressionFunction> function : referencedFunctions.entrySet()) { - ExpressionFunction optimizedFunction = optimize(function.getValue(), - contextPrototypes.get(function.getKey().functionName())); - functionsBuilder.put(function.getKey(), optimizedFunction); - } - this.referencedFunctions = functionsBuilder.build(); + this.referencedFunctions = Map.copyOf(referencedFunctions.entrySet().stream() + .collect(CustomCollectors.toLinkedMap(f -> f.getKey(), f -> optimize(f.getValue(), contextPrototypes.get(f.getKey().functionName()))))); } /** Returns an optimized version of the given function */ @@ -142,7 +138,7 @@ public class Model { } /** Returns an immutable map of the referenced function instances of this */ - Map<FunctionReference, ExpressionFunction> referencedFunctions() { return referencedFunctions; } + Map<FunctionReference, ExpressionFunction> referencedFunctions() { return Map.copyOf(referencedFunctions); } /** Returns the given referred function, or throws a IllegalArgumentException if it does not exist */ ExpressionFunction requireReferencedFunction(FunctionReference reference) { diff --git a/model-evaluation/src/main/java/ai/vespa/models/evaluation/ModelsEvaluator.java b/model-evaluation/src/main/java/ai/vespa/models/evaluation/ModelsEvaluator.java index 88843fd99ab..40a503e0212 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/evaluation/ModelsEvaluator.java +++ b/model-evaluation/src/main/java/ai/vespa/models/evaluation/ModelsEvaluator.java @@ -2,7 +2,6 @@ package ai.vespa.models.evaluation; import com.yahoo.api.annotations.Beta; -import com.google.common.collect.ImmutableMap; import com.yahoo.component.annotation.Inject; import com.yahoo.component.AbstractComponent; import com.yahoo.filedistribution.fileacquirer.FileAcquirer; @@ -23,7 +22,7 @@ import java.util.Map; @Beta public class ModelsEvaluator extends AbstractComponent { - private final ImmutableMap<String, Model> models; + private final Map<String, Model> models; @Inject public ModelsEvaluator(RankProfilesConfig config, @@ -43,7 +42,7 @@ public class ModelsEvaluator extends AbstractComponent { } public ModelsEvaluator(Map<String, Model> models) { - this.models = ImmutableMap.copyOf(models); + this.models = Map.copyOf(models); } /** Returns the models of this as an immutable map */ diff --git a/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java b/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java index 2661b9c2eb2..78addf0328a 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java +++ b/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java @@ -102,9 +102,8 @@ public class ModelsEvaluationHandler extends ThreadedHttpRequestHandler { private HttpResponse listAllModels(HttpRequest request) { Slime slime = new Slime(); Cursor root = slime.setObject(); - for (String modelName: modelsEvaluator.models().keySet()) { - root.setString(modelName, baseUrl(request) + modelName); - } + modelsEvaluator.models().keySet().stream().sorted() + .forEach(name -> root.setString(name, baseUrl(request) + name)); return new Response(200, com.yahoo.slime.JsonFormat.toJsonBytes(slime)); } diff --git a/model-evaluation/src/test/java/ai/vespa/models/evaluation/ModelsEvaluatorTest.java b/model-evaluation/src/test/java/ai/vespa/models/evaluation/ModelsEvaluatorTest.java index c4e859bec9f..f09bac63085 100644 --- a/model-evaluation/src/test/java/ai/vespa/models/evaluation/ModelsEvaluatorTest.java +++ b/model-evaluation/src/test/java/ai/vespa/models/evaluation/ModelsEvaluatorTest.java @@ -75,7 +75,7 @@ public class ModelsEvaluatorTest { evaluator.evaluate(); } catch (IllegalStateException e) { - assertEquals("Argument 'arg2' must be bound to a value of type tensor(d1{})", + assertEquals("Argument 'arg1' must be bound to a value of type tensor(d0[1])", Exceptions.toMessageString(e)); } @@ -88,6 +88,15 @@ public class ModelsEvaluatorTest { assertEquals("Argument 'arg1' must be bound to a value of type tensor(d0[1])", Exceptions.toMessageString(e)); } + try { // Just the other binding + FunctionEvaluator evaluator = model.evaluatorOf("test"); + evaluator.bind("arg1", Tensor.from(TensorType.fromSpec("tensor(d0[1])"), "{{d0:0}:0.1}")); + evaluator.evaluate(); + } + catch (IllegalStateException e) { + assertEquals("Argument 'arg2' must be bound to a value of type tensor(d1{})", + Exceptions.toMessageString(e)); + } try { // Wrong binding argument FunctionEvaluator evaluator = model.evaluatorOf("test"); diff --git a/model-evaluation/src/test/java/ai/vespa/models/handler/HandlerTester.java b/model-evaluation/src/test/java/ai/vespa/models/handler/HandlerTester.java index fc05a9936a9..3b16be311a0 100644 --- a/model-evaluation/src/test/java/ai/vespa/models/handler/HandlerTester.java +++ b/model-evaluation/src/test/java/ai/vespa/models/handler/HandlerTester.java @@ -10,7 +10,6 @@ import com.yahoo.tensor.serialization.JsonFormat; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Collections; import java.util.Map; import java.util.concurrent.Executors; @@ -25,19 +24,19 @@ class HandlerTester { } void assertResponse(String url, int expectedCode) { - assertResponse(url, Collections.emptyMap(), expectedCode, (String)null); + assertResponse(url, Map.of(), expectedCode, (String)null); } void assertResponse(String url, int expectedCode, String expectedResult) { - assertResponse(url, Collections.emptyMap(), expectedCode, expectedResult); + assertResponse(url, Map.of(), expectedCode, expectedResult); } void assertResponse(String url, int expectedCode, String expectedResult, Map<String, String> headers) { - assertResponse(url, Collections.emptyMap(), expectedCode, expectedResult, headers); + assertResponse(url, Map.of(), expectedCode, expectedResult, headers); } void assertResponse(String url, Map<String, String> properties, int expectedCode, String expectedResult) { - assertResponse(url, properties, expectedCode, expectedResult, Collections.emptyMap()); + assertResponse(url, properties, expectedCode, expectedResult, Map.of()); } void assertResponse(String url, Map<String, String> properties, int expectedCode, String expectedResult, Map<String, String> headers) { diff --git a/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java b/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java index 0de8ce5f061..d804e50c67d 100644 --- a/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java +++ b/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java @@ -49,16 +49,30 @@ public class ModelsEvaluationHandlerTest { @Test public void testListModels() { String url = "http://localhost/model-evaluation/v1"; - String expected = - "{\"mnist_softmax\":\"http://localhost/model-evaluation/v1/mnist_softmax\",\"xgboost_non_standalone\":\"http://localhost/model-evaluation/v1/xgboost_non_standalone\",\"mnist_saved\":\"http://localhost/model-evaluation/v1/mnist_saved\",\"mnist_softmax_saved\":\"http://localhost/model-evaluation/v1/mnist_softmax_saved\",\"vespa_model\":\"http://localhost/model-evaluation/v1/vespa_model\",\"xgboost_2_2\":\"http://localhost/model-evaluation/v1/xgboost_2_2\",\"lightgbm_regression\":\"http://localhost/model-evaluation/v1/lightgbm_regression\"}"; + String expected = "{" + + "\"lightgbm_regression\":\"http://localhost/model-evaluation/v1/lightgbm_regression\"," + + "\"mnist_saved\":\"http://localhost/model-evaluation/v1/mnist_saved\"," + + "\"mnist_softmax\":\"http://localhost/model-evaluation/v1/mnist_softmax\"," + + "\"mnist_softmax_saved\":\"http://localhost/model-evaluation/v1/mnist_softmax_saved\"," + + "\"vespa_model\":\"http://localhost/model-evaluation/v1/vespa_model\"," + + "\"xgboost_2_2\":\"http://localhost/model-evaluation/v1/xgboost_2_2\"," + + "\"xgboost_non_standalone\":\"http://localhost/model-evaluation/v1/xgboost_non_standalone\"" + + "}"; handler.assertResponse(url, 200, expected); } @Test public void testListModelsWithDifferentHost() { String url = "http://localhost/model-evaluation/v1"; - String expected = - "{\"mnist_softmax\":\"http://localhost:8088/model-evaluation/v1/mnist_softmax\",\"xgboost_non_standalone\":\"http://localhost:8088/model-evaluation/v1/xgboost_non_standalone\",\"mnist_saved\":\"http://localhost:8088/model-evaluation/v1/mnist_saved\",\"mnist_softmax_saved\":\"http://localhost:8088/model-evaluation/v1/mnist_softmax_saved\",\"vespa_model\":\"http://localhost:8088/model-evaluation/v1/vespa_model\",\"xgboost_2_2\":\"http://localhost:8088/model-evaluation/v1/xgboost_2_2\",\"lightgbm_regression\":\"http://localhost:8088/model-evaluation/v1/lightgbm_regression\"}"; + String expected = "{" + + "\"lightgbm_regression\":\"http://localhost:8088/model-evaluation/v1/lightgbm_regression\"," + + "\"mnist_saved\":\"http://localhost:8088/model-evaluation/v1/mnist_saved\"," + + "\"mnist_softmax\":\"http://localhost:8088/model-evaluation/v1/mnist_softmax\"," + + "\"mnist_softmax_saved\":\"http://localhost:8088/model-evaluation/v1/mnist_softmax_saved\"," + + "\"vespa_model\":\"http://localhost:8088/model-evaluation/v1/vespa_model\"," + + "\"xgboost_2_2\":\"http://localhost:8088/model-evaluation/v1/xgboost_2_2\"," + + "\"xgboost_non_standalone\":\"http://localhost:8088/model-evaluation/v1/xgboost_non_standalone\"" + + "}"; handler.assertResponse(url, 200, expected, Map.of("Host", "localhost:8088")); } diff --git a/model-integration/pom.xml b/model-integration/pom.xml index 7d3ab3f7a5f..63232b61106 100644 --- a/model-integration/pom.xml +++ b/model-integration/pom.xml @@ -16,12 +16,6 @@ <packaging>container-plugin</packaging> <dependencies> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - - <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>annotations</artifactId> <version>${project.version}</version> @@ -59,12 +53,6 @@ </dependency> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <scope>provided</scope> - </dependency> - - <dependency> <groupId>com.microsoft.onnxruntime</groupId> <artifactId>onnxruntime</artifactId> </dependency> @@ -72,6 +60,17 @@ <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> <plugins> diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/ImportedModel.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/ImportedModel.java index 35c409a637c..8c55e6793c0 100644 --- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/ImportedModel.java +++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/ImportedModel.java @@ -1,20 +1,19 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.rankingexpression.importer; -import com.google.common.collect.ImmutableMap; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlFunction; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModel; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.io.IOUtils; import com.yahoo.searchlib.rankingexpression.RankingExpression; import com.yahoo.searchlib.rankingexpression.parser.ParseException; +import com.yahoo.stream.CustomCollectors; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -73,7 +72,7 @@ public class ImportedModel implements ImportedMlModel { public String toString() { return "imported model '" + name + "' from " + source; } /** Returns an immutable map of the inputs of this */ - public Map<String, TensorType> inputs() { return Collections.unmodifiableMap(inputs); } + public Map<String, TensorType> inputs() { return Map.copyOf(inputs); } @Override public Optional<String> inputTypeSpec(String input) { @@ -121,7 +120,7 @@ public class ImportedModel implements ImportedMlModel { * which are not Inputs/Placeholders or Variables (which instead become respectively inputs and constants). * Note that only nodes recursively referenced by a placeholder/input are added. */ - public Map<String, RankingExpression> expressions() { return Collections.unmodifiableMap(expressions); } + public Map<String, RankingExpression> expressions() { return Map.copyOf(expressions); } /** * Returns an immutable map of the functions that are part of this model. @@ -130,7 +129,7 @@ public class ImportedModel implements ImportedMlModel { public Map<String, String> functions() { return asExpressionStrings(functions); } /** Returns an immutable map of the signatures of this */ - public Map<String, Signature> signatures() { return Collections.unmodifiableMap(signatures); } + public Map<String, Signature> signatures() { return Map.copyOf(signatures); } /** Returns the given signature. If it does not already exist it is added to this. */ public Signature signature(String name) { @@ -270,30 +269,29 @@ public class ImportedModel implements ImportedMlModel { * Returns an immutable map of the inputs (evaluation context) of this. This is a map from input name * in this signature to input name in the owning model */ - public Map<String, String> inputs() { return Collections.unmodifiableMap(inputs); } + public Map<String, String> inputs() { return Map.copyOf(inputs); } /** Returns the name and type of all inputs in this signature as an immutable map */ Map<String, TensorType> inputMap() { - ImmutableMap.Builder<String, TensorType> inputs = new ImmutableMap.Builder<>(); // Note: We're naming inputs by their actual name (used in the expression, given by what the input maps *to* // in the model, as these are the names which must actually be bound, if we are to avoid creating an // "input mapping" to accommodate this complexity - for (Map.Entry<String, String> inputEntry : inputs().entrySet()) - inputs.put(inputEntry.getValue(), owner().inputs().get(inputEntry.getValue())); - return inputs.build(); + return Map.copyOf(inputs.entrySet() + .stream() + .collect(CustomCollectors.toLinkedMap(Map.Entry::getValue, e -> owner().inputs.get(e.getValue())))); } /** Returns the type of the input this input references */ public TensorType inputArgument(String inputName) { return owner().inputs().get(inputs.get(inputName)); } /** Returns an immutable list of the expression names of this */ - public Map<String, String> outputs() { return Collections.unmodifiableMap(outputs); } + public Map<String, String> outputs() { return Map.copyOf(outputs); } /** * Returns an immutable list of the outputs of this which could not be imported, * with a string detailing the reason for each */ - public Map<String, String> skippedOutputs() { return Collections.unmodifiableMap(skippedOutputs); } + public Map<String, String> skippedOutputs() { return Map.copyOf(skippedOutputs); } /** Returns the expression this output references as an imported function */ public ImportedMlFunction outputFunction(String outputName, String functionName) { diff --git a/model-integration/src/test/java/ai/vespa/rankingexpression/importer/vespa/VespaImportTestCase.java b/model-integration/src/test/java/ai/vespa/rankingexpression/importer/vespa/VespaImportTestCase.java index d9c7e67c946..75e31d66e5b 100644 --- a/model-integration/src/test/java/ai/vespa/rankingexpression/importer/vespa/VespaImportTestCase.java +++ b/model-integration/src/test/java/ai/vespa/rankingexpression/importer/vespa/VespaImportTestCase.java @@ -10,7 +10,8 @@ import com.yahoo.searchlib.rankingexpression.parser.ParseException; import com.yahoo.tensor.Tensor; import org.junit.Test; -import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -51,9 +52,12 @@ public class VespaImportTestCase { assertEquals("reduce(reduce(input1 * input2, sum, name) * constant(constant1asLarge), max, x) * constant2", model.expressions().get("foo2").getRoot().toString()); - List<ImportedMlFunction> functions = model.outputExpressions(); - assertEquals(2, functions.size()); - ImportedMlFunction foo1Function = functions.get(0); + Map<String, ImportedMlFunction> byName = model.outputExpressions().stream() + .collect(Collectors.toUnmodifiableMap(ImportedMlFunction::name, f -> f)); + assertEquals(2, byName.size()); + assertTrue(byName.containsKey("foo1")); + assertTrue(byName.containsKey("foo2")); + ImportedMlFunction foo1Function = byName.get("foo1"); assertEquals("foo1", foo1Function.name()); assertEquals("reduce(reduce(input1 * input2, sum, name) * constant1, max, x) * constant2", foo1Function.expression()); assertEquals("tensor():{202.5}", evaluate(foo1Function, "{{name:a, x:0}: 1, {name:a, x:1}: 2, {name:a, x:2}: 3}").toString()); diff --git a/opennlp-linguistics/pom.xml b/opennlp-linguistics/pom.xml index 40f1e95f4f4..a7907ba212f 100644 --- a/opennlp-linguistics/pom.xml +++ b/opennlp-linguistics/pom.xml @@ -53,12 +53,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - <scope>provided</scope> - <classifier>no_aop</classifier> - </dependency> - <dependency> <groupId>org.apache.opennlp</groupId> <artifactId>opennlp-tools</artifactId> </dependency> diff --git a/searchlib/src/main/java/com/yahoo/searchlib/ranking/features/fieldmatch/Field.java b/searchlib/src/main/java/com/yahoo/searchlib/ranking/features/fieldmatch/Field.java index 9492cebc608..3f711df4fdd 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/ranking/features/fieldmatch/Field.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/ranking/features/fieldmatch/Field.java @@ -1,8 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchlib.ranking.features.fieldmatch; -import com.google.common.collect.ImmutableList; - +import java.util.Arrays; import java.util.List; /** @@ -12,19 +11,17 @@ import java.util.List; */ public class Field { - private final ImmutableList<Term> terms; + private final List<Term> terms; /** Creates a field from a space-separated string */ public Field(String fieldString) { - ImmutableList.Builder<Term> list = new ImmutableList.Builder<>(); - for (String term : fieldString.split(" ")) - list.add(new Term(term)); - this.terms = list.build(); + terms = Arrays.stream(fieldString.split(" ")).map(Term::new).toList(); + } /** Creates a field from a list of terms */ public Field(List<Term> terms) { - this.terms = ImmutableList.copyOf(terms); + this.terms = List.copyOf(terms); } /** Returns an immutable list of the terms in this */ diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/ExpressionFunction.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/ExpressionFunction.java index eac87ff2f12..241a53fb458 100755 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/ExpressionFunction.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/ExpressionFunction.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.searchlib.rankingexpression; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.yahoo.searchlib.rankingexpression.rule.ConstantNode; import com.yahoo.searchlib.rankingexpression.rule.ExpressionNode; import com.yahoo.searchlib.rankingexpression.rule.FunctionNode; @@ -36,10 +34,10 @@ import java.util.Optional; public class ExpressionFunction { private final String name; - private final ImmutableList<String> arguments; + private final List<String> arguments; /** Types of the inputs, if known. The keys here is any subset (including empty and identity) of the argument list */ - private final ImmutableMap<String, TensorType> argumentTypes; + private final Map<String, TensorType> argumentTypes; private final RankingExpression body; private final Optional<TensorType> returnType; @@ -62,17 +60,17 @@ public class ExpressionFunction { * @param body the ranking expression that defines this function */ public ExpressionFunction(String name, List<String> arguments, RankingExpression body) { - this(name, arguments, body, ImmutableMap.of(), Optional.empty()); + this(name, arguments, body, Map.of(), Optional.empty()); } public ExpressionFunction(String name, List<String> arguments, RankingExpression body, Map<String, TensorType> argumentTypes, Optional<TensorType> returnType) { this.name = Objects.requireNonNull(name, "name cannot be null"); - this.arguments = arguments==null ? ImmutableList.of() : ImmutableList.copyOf(arguments); + this.arguments = arguments==null ? List.of() : List.copyOf(arguments); this.body = Objects.requireNonNull(body, "body cannot be null"); if ( ! this.arguments.containsAll(argumentTypes.keySet())) throw new IllegalArgumentException("Argument type keys must be a subset of the argument keys"); - this.argumentTypes = ImmutableMap.copyOf(argumentTypes); + this.argumentTypes = Map.copyOf(argumentTypes); this.returnType = Objects.requireNonNull(returnType, "returnType cannot be null"); } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/AbstractArrayContext.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/AbstractArrayContext.java index 340556b7e2d..4d6ac0104c7 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/AbstractArrayContext.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/AbstractArrayContext.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.searchlib.rankingexpression.evaluation; -import com.google.common.collect.ImmutableMap; +import com.yahoo.lang.MutableInteger; import com.yahoo.searchlib.rankingexpression.RankingExpression; import com.yahoo.searchlib.rankingexpression.rule.CompositeNode; import com.yahoo.searchlib.rankingexpression.rule.ExpressionNode; import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode; +import com.yahoo.stream.CustomCollectors; import java.util.BitSet; import java.util.LinkedHashSet; @@ -116,7 +117,7 @@ public abstract class AbstractArrayContext extends Context implements Cloneable, private static class IndexedBindings implements Cloneable { /** The mapping from variable name to index */ - private final ImmutableMap<String, Integer> nameToIndex; + private final Map<String, Integer> nameToIndex; /** The current values set, pre-converted to doubles */ private double[] doubleValues; @@ -125,7 +126,7 @@ public abstract class AbstractArrayContext extends Context implements Cloneable, private BitSet setValues; /** Value to return if value is missing. */ - private double missingValue; + private final double missingValue; public IndexedBindings(RankingExpression expression, Value missingValue) { Set<String> bindTargets = new LinkedHashSet<>(); @@ -138,11 +139,8 @@ public abstract class AbstractArrayContext extends Context implements Cloneable, doubleValues[i] = this.missingValue; } - int i = 0; - ImmutableMap.Builder<String, Integer> nameToIndexBuilder = new ImmutableMap.Builder<>(); - for (String variable : bindTargets) - nameToIndexBuilder.put(variable,i++); - nameToIndex = nameToIndexBuilder.build(); + MutableInteger index = new MutableInteger(0); + nameToIndex = bindTargets.stream().collect(CustomCollectors.toLinkedMap(name -> name, name -> index.next())); } private void extractBindTargets(ExpressionNode node, Set<String> bindTargets) { @@ -152,8 +150,7 @@ public abstract class AbstractArrayContext extends Context implements Cloneable, ": Array lookup is not supported with features having arguments)"); bindTargets.add(node.toString()); } - else if (node instanceof CompositeNode) { - CompositeNode cNode = (CompositeNode)node; + else if (node instanceof CompositeNode cNode) { for (ExpressionNode child : cNode.children()) extractBindTargets(child, bindTargets); } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/Arguments.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/Arguments.java index e770e6ac038..b716b693011 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/Arguments.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/Arguments.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.searchlib.rankingexpression.rule; -import com.google.common.collect.ImmutableList; import com.yahoo.searchlib.rankingexpression.evaluation.Context; import com.yahoo.searchlib.rankingexpression.evaluation.Value; @@ -18,27 +17,23 @@ public final class Arguments implements Serializable { public static final Arguments EMPTY = new Arguments(); - private final ImmutableList<ExpressionNode> expressions; + private final List<ExpressionNode> expressions; public Arguments() { - this(ImmutableList.of()); + this(List.of()); } public Arguments(ExpressionNode singleArgument) { - this(ImmutableList.of(singleArgument)); + this(List.of(singleArgument)); } public Arguments(List<? extends ExpressionNode> expressions) { if (expressions == null) { - this.expressions = ImmutableList.of(); + this.expressions = List.of(); return; } - // Build in a roundabout way because java generics and lists - ImmutableList.Builder<ExpressionNode> b = ImmutableList.builder(); - for (ExpressionNode node : expressions) - b.add(node); - this.expressions = b.build(); + this.expressions = List.copyOf(expressions); } /** Returns an unmodifiable list of the expressions in this, never null */ diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/LambdaFunctionNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/LambdaFunctionNode.java index 97e9a74f9c8..9c0c0e46804 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/LambdaFunctionNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/LambdaFunctionNode.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.searchlib.rankingexpression.rule; -import com.google.common.collect.ImmutableList; import com.yahoo.searchlib.rankingexpression.Reference; import com.yahoo.searchlib.rankingexpression.evaluation.Context; import com.yahoo.searchlib.rankingexpression.evaluation.MapContext; @@ -27,7 +26,7 @@ import java.util.stream.Collectors; */ public class LambdaFunctionNode extends CompositeNode { - private final ImmutableList<String> arguments; + private final List<String> arguments; private final ExpressionNode functionExpression; public LambdaFunctionNode(List<String> arguments, ExpressionNode functionExpression) { @@ -37,7 +36,7 @@ public class LambdaFunctionNode extends CompositeNode { .filter(f -> ! arguments.contains(f)) .collect(Collectors.joining(", "))); } - this.arguments = ImmutableList.copyOf(arguments); + this.arguments = List.copyOf(arguments); this.functionExpression = functionExpression; } @@ -106,15 +105,12 @@ public class LambdaFunctionNode extends CompositeNode { } private Optional<DoubleBinaryOperator> getDirectEvaluator() { - if ( ! (functionExpression instanceof OperationNode)) { + if ( ! (functionExpression instanceof OperationNode node)) { return Optional.empty(); } - OperationNode node = (OperationNode) functionExpression; - if ( ! (node.children().get(0) instanceof ReferenceNode) || ! (node.children().get(1) instanceof ReferenceNode)) { + if ( ! (node.children().get(0) instanceof ReferenceNode lhs) || ! (node.children().get(1) instanceof ReferenceNode rhs)) { return Optional.empty(); } - var lhs = (ReferenceNode) node.children().get(0); - var rhs = (ReferenceNode) node.children().get(1); if (! lhs.getName().equals(arguments.get(0)) || ! rhs.getName().equals(arguments.get(1))) { return Optional.empty(); } @@ -122,17 +118,17 @@ public class LambdaFunctionNode extends CompositeNode { return Optional.empty(); } Operator operator = node.operators().get(0); - switch (operator) { - case or: return asFunctionExpression((left, right) -> ((left != 0.0) || (right != 0.0)) ? 1.0 : 0.0); - case and: return asFunctionExpression((left, right) -> ((left != 0.0) && (right != 0.0)) ? 1.0 : 0.0); - case plus: return asFunctionExpression((left, right) -> left + right); - case minus: return asFunctionExpression((left, right) -> left - right); - case multiply: return asFunctionExpression((left, right) -> left * right); - case divide: return asFunctionExpression((left, right) -> left / right); - case modulo: return asFunctionExpression((left, right) -> left % right); - case power: return asFunctionExpression(Math::pow); - } - return Optional.empty(); + return switch (operator) { + case or -> asFunctionExpression((left, right) -> ((left != 0.0) || (right != 0.0)) ? 1.0 : 0.0); + case and -> asFunctionExpression((left, right) -> ((left != 0.0) && (right != 0.0)) ? 1.0 : 0.0); + case plus -> asFunctionExpression((left, right) -> left + right); + case minus -> asFunctionExpression((left, right) -> left - right); + case multiply -> asFunctionExpression((left, right) -> left * right); + case divide -> asFunctionExpression((left, right) -> left / right); + case modulo -> asFunctionExpression((left, right) -> left % right); + case power -> asFunctionExpression(Math::pow); + default -> Optional.empty(); + }; } private Optional<DoubleBinaryOperator> asFunctionExpression(DoubleBinaryOperator operator) { diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SetMembershipNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SetMembershipNode.java index 5da2fbfe624..6b87f75d884 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SetMembershipNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SetMembershipNode.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.searchlib.rankingexpression.rule; -import com.google.common.collect.ImmutableList; import com.yahoo.searchlib.rankingexpression.Reference; import com.yahoo.searchlib.rankingexpression.evaluation.BooleanValue; import com.yahoo.searchlib.rankingexpression.evaluation.Context; @@ -30,7 +29,7 @@ public class SetMembershipNode extends BooleanNode { public SetMembershipNode(ExpressionNode testValue, List<ExpressionNode> setValues) { this.testValue = testValue; - this.setValues = ImmutableList.copyOf(setValues); + this.setValues = List.copyOf(setValues); } /** The value to check for membership in the set */ diff --git a/searchlib/src/test/java/com/yahoo/searchlib/ranking/features/fieldmatch/test/FieldMatchMetricsTestCase.java b/searchlib/src/test/java/com/yahoo/searchlib/ranking/features/fieldmatch/test/FieldMatchMetricsTestCase.java index f4a003868f8..41a6cd69878 100644 --- a/searchlib/src/test/java/com/yahoo/searchlib/ranking/features/fieldmatch/test/FieldMatchMetricsTestCase.java +++ b/searchlib/src/test/java/com/yahoo/searchlib/ranking/features/fieldmatch/test/FieldMatchMetricsTestCase.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.searchlib.ranking.features.fieldmatch.test; -import com.google.common.collect.ImmutableList; import com.yahoo.searchlib.ranking.features.fieldmatch.Field; import com.yahoo.searchlib.ranking.features.fieldmatch.FieldMatchMetrics; import com.yahoo.searchlib.ranking.features.fieldmatch.FieldMatchMetricsComputer; @@ -10,6 +9,7 @@ import com.yahoo.searchlib.ranking.features.fieldmatch.QueryTerm; import com.yahoo.searchlib.ranking.features.fieldmatch.Query; import org.junit.Test; +import java.util.ArrayList; import java.util.List; import static org.junit.Assert.assertEquals; @@ -776,9 +776,9 @@ public class FieldMatchMetricsTestCase { } private Field toField(String fieldString) { - if (fieldString.length() == 0) return new Field(ImmutableList.of()); + if (fieldString.length() == 0) return new Field(List.of()); - ImmutableList.Builder<Field.Term> terms = new ImmutableList.Builder<>(); + List<Field.Term> terms = new ArrayList<>(); for (String termString : fieldString.split(" ")) { String[] colonSplit = termString.split(":"); if (colonSplit.length > 1) @@ -786,7 +786,7 @@ public class FieldMatchMetricsTestCase { else terms.add(new Field.Term(colonSplit[0])); } - return new Field(terms.build()); + return new Field(List.copyOf(terms)); } } diff --git a/service-monitor/pom.xml b/service-monitor/pom.xml index 6a46838a0ce..2378d63d457 100644 --- a/service-monitor/pom.xml +++ b/service-monitor/pom.xml @@ -91,12 +91,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - <scope>provided</scope> - <classifier>no_aop</classifier> - </dependency> - <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>${jackson2.version}</version> diff --git a/vdslib/pom.xml b/vdslib/pom.xml index c534b2024ed..4067fc9d8d4 100644 --- a/vdslib/pom.xml +++ b/vdslib/pom.xml @@ -15,11 +15,6 @@ <description> </description> <dependencies> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/zkfacade/pom.xml b/zkfacade/pom.xml index 9c5ed23636f..d9a9cb51c89 100644 --- a/zkfacade/pom.xml +++ b/zkfacade/pom.xml @@ -58,11 +58,6 @@ </exclusions> </dependency> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <exclusions> |