diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-30 10:04:50 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-30 10:04:50 +0100 |
commit | 448231f18ba53edf5c0e7ab4b6732ef69328281c (patch) | |
tree | 289f528fd6adac2a39e636c449c633c26fdb838e /vespajlib/src/main/java/com/yahoo/tensor | |
parent | 711362f17d4bbece0dc2d0833a22063374ae3e04 (diff) |
Reduce the simple usage of guava where java has caught up
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/tensor')
15 files changed, 55 insertions, 102 deletions
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) { |