diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-04-15 09:18:56 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-04-15 10:42:35 +0000 |
commit | ce42f04b4781c9f7f31c66c0e24ca6d762d07ff0 (patch) | |
tree | 113e62896bb547aec1144e1a88f12e4e847fd28a /vespajlib | |
parent | aebe857d5bf307597c601303810b089a44e57fd8 (diff) |
remove duplicated code
Diffstat (limited to 'vespajlib')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.java | 13 |
1 files changed, 2 insertions, 11 deletions
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 48604df87e4..797b890dcb9 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Reduce.java @@ -104,16 +104,7 @@ public class Reduce<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET @Override public TensorType type(TypeContext<NAMETYPE> context) { - return type(argument.type(context), dimensions); - } - - private static TensorType type(TensorType argumentType, List<String> dimensions) { - TensorType.Builder builder = new TensorType.Builder(argumentType.valueType()); - if (dimensions.isEmpty()) return builder.build(); // means reduce all - for (TensorType.Dimension dimension : argumentType.dimensions()) - if ( ! dimensions.contains(dimension.name())) // keep - builder.dimension(dimension); - return builder.build(); + return outputType(argument.type(context), dimensions); } @Override @@ -133,7 +124,7 @@ public class Reduce<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAMET else return reduceAllGeneral(argument, aggregator); - TensorType reducedType = type(argument.type(), dimensions); + TensorType reducedType = outputType(argument.type(), dimensions); // Reduce cells Map<TensorAddress, ValueAggregator> aggregatingCells = new HashMap<>(); |