summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-12-16 11:32:02 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2016-12-16 11:32:02 +0100
commitd8d1f9173a6d25e16f687ad19c2c3ed920299fb0 (patch)
treede0a47d3bea3586f28e6eb28aa579e187da4f8b4
parent3fce5f3477863fcf39a55a2232c6fa920ea09ed6 (diff)
Improve API
-rw-r--r--searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTester.java2
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorType.java14
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorTypeParser.java4
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/IndexedTensorTestCase.java24
4 files changed, 20 insertions, 24 deletions
diff --git a/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTester.java b/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTester.java
index 1017dd02f96..2ce3d5b5eca 100644
--- a/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTester.java
+++ b/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTester.java
@@ -84,7 +84,7 @@ public class EvaluationTester {
else { // convert to indexed
TensorType.Builder builder = new TensorType.Builder();
for (TensorType.Dimension dimension : tensor.type().dimensions())
- builder.indexedUnbound(dimension.name());
+ builder.indexed(dimension.name());
return builder.build();
}
}
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
index 3ac16b5d259..0c726efc047 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
@@ -7,7 +7,6 @@ import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -149,7 +148,7 @@ public class TensorType {
public final String name() { return name; }
- /** Returns the size of this dimension if it is indexedUnbound, empty otherwise */
+ /** Returns the size of this dimension if it is bound, empty otherwise */
public abstract Optional<Integer> size();
public abstract Type type();
@@ -312,12 +311,11 @@ public class TensorType {
return this;
}
- // TODO: Rename this and the next to "indexed" as they can be separated parameters (and check system tests)
- public Builder indexedBound(String name, int size) {
- return add(new IndexedBoundDimension(name, size));
- }
+ /** Create a bound indexed dimension */
+ public Builder indexed(String name, int size) { return add(new IndexedBoundDimension(name, size)); }
- public Builder indexedUnbound(String name) {
+ /** Create an unbound indexed dimension */
+ public Builder indexed(String name) {
return add(new IndexedUnboundDimension(name));
}
@@ -332,7 +330,7 @@ public class TensorType {
public Builder dimension(String name, Dimension.Type type) {
switch (type) {
case mapped : mapped(name); break;
- case indexedUnbound : indexedUnbound(name); break;
+ case indexedUnbound : indexed(name); break;
default : throw new IllegalArgumentException("This can not create a dimension of type " + type);
}
return this;
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorTypeParser.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorTypeParser.java
index 6c209e432c5..f7b71c2149a 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorTypeParser.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/TensorTypeParser.java
@@ -48,9 +48,9 @@ class TensorTypeParser {
String dimensionName = matcher.group(1);
String dimensionSize = matcher.group(2);
if (dimensionSize.isEmpty()) {
- builder.indexedUnbound(dimensionName);
+ builder.indexed(dimensionName);
} else {
- builder.indexedBound(dimensionName, Integer.valueOf(dimensionSize));
+ builder.indexed(dimensionName, Integer.valueOf(dimensionSize));
}
return true;
}
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/IndexedTensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/IndexedTensorTestCase.java
index da4b300c3ab..38c3cb106c1 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/IndexedTensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/IndexedTensorTestCase.java
@@ -2,8 +2,6 @@ package com.yahoo.tensor;
import org.junit.Test;
-import java.util.Arrays;
-
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
@@ -34,7 +32,7 @@ public class IndexedTensorTestCase {
assertEquals("{3.5}", singleValue.toString());
assertEquals("{3.5}", Tensor.from(TensorType.empty, "{3.5}").toString());
- TensorType type = new TensorType.Builder().indexedUnbound("x").indexedUnbound("y").build();
+ TensorType type = new TensorType.Builder().indexed("x").indexed("y").build();
Tensor emptyWithDimensions = Tensor.Builder.of(type).build();
assertTrue(emptyWithDimensions instanceof IndexedTensor);
assertEquals("tensor(x[],y[]):{}", emptyWithDimensions.toString());
@@ -46,22 +44,22 @@ public class IndexedTensorTestCase {
@Test
public void testBoundBuilding() {
- TensorType type = new TensorType.Builder().indexedBound("v", vSize)
- .indexedBound("w", wSize)
- .indexedBound("x", xSize)
- .indexedBound("y", ySize)
- .indexedBound("z", zSize)
+ TensorType type = new TensorType.Builder().indexed("v", vSize)
+ .indexed("w", wSize)
+ .indexed("x", xSize)
+ .indexed("y", ySize)
+ .indexed("z", zSize)
.build();
assertBuildingVWXYZ(type);
}
@Test
public void testUnboundBuilding() {
- TensorType type = new TensorType.Builder().indexedUnbound("w")
- .indexedUnbound("v")
- .indexedUnbound("x")
- .indexedUnbound("y")
- .indexedUnbound("z").build();
+ TensorType type = new TensorType.Builder().indexed("w")
+ .indexed("v")
+ .indexed("x")
+ .indexed("y")
+ .indexed("z").build();
assertBuildingVWXYZ(type);
}