summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2022-05-18 14:11:54 +0200
committerGitHub <noreply@github.com>2022-05-18 14:11:54 +0200
commit2c9cb8159adaced573fd1e34689e533946feea85 (patch)
treeaad434533f9514747e80f339d87b984088e2f1f7 /vespajlib
parenta4dbfc43c7df534ee5b032204ef19a7b038d7e3e (diff)
parentc080a3c9b1ebd39b947aeddd1e5a0bf5e46d474c (diff)
Merge pull request #22642 from vespa-engine/revert-22637-bratseth/model-syntax
Revert "Bratseth/model syntax"
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/abi-spec.json12
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorAddress.java49
2 files changed, 10 insertions, 51 deletions
diff --git a/vespajlib/abi-spec.json b/vespajlib/abi-spec.json
index 654042372cf..f7be61946ba 100644
--- a/vespajlib/abi-spec.json
+++ b/vespajlib/abi-spec.json
@@ -1273,18 +1273,6 @@
],
"fields": []
},
- "com.yahoo.tensor.TensorAddress$PartialBuilder": {
- "superClass": "com.yahoo.tensor.TensorAddress$Builder",
- "interfaces": [],
- "attributes": [
- "public"
- ],
- "methods": [
- "public void <init>(com.yahoo.tensor.TensorType)",
- "public com.yahoo.tensor.TensorAddress$Builder copy()"
- ],
- "fields": []
- },
"com.yahoo.tensor.TensorAddress": {
"superClass": "java.lang.Object",
"interfaces": [
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorAddress.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorAddress.java
index 92bdfb2b3a4..d9ab67d6c5f 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorAddress.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/TensorAddress.java
@@ -61,10 +61,8 @@ public abstract class TensorAddress implements Comparable<TensorAddress> {
@Override
public int hashCode() {
int result = 1;
- for (int i = 0; i < size(); i++) {
- if (label(i) != null)
- result = 31 * result + label(i).hashCode();
- }
+ for (int i = 0; i < size(); i++)
+ result = 31 * result + label(i).hashCode();
return result;
}
@@ -75,7 +73,7 @@ public abstract class TensorAddress implements Comparable<TensorAddress> {
TensorAddress other = (TensorAddress)o;
if (other.size() != this.size()) return false;
for (int i = 0; i < this.size(); i++)
- if ( ! Objects.equals(this.label(i), other.label(i)))
+ if ( ! this.label(i).equals(other.label(i)))
return false;
return true;
}
@@ -173,8 +171,8 @@ public abstract class TensorAddress implements Comparable<TensorAddress> {
/** Builder of a tensor address */
public static class Builder {
- final TensorType type;
- final String[] labels;
+ private final TensorType type;
+ private final String[] labels;
public Builder(TensorType type) {
this(type, new String[type.dimensions().size()]);
@@ -186,16 +184,14 @@ public abstract class TensorAddress implements Comparable<TensorAddress> {
}
/**
- * Adds the label to the only mapped dimension of this.
+ * Adds the label to the only dimension of this.
*
* @throws IllegalArgumentException if this does not have exactly one dimension
*/
public Builder add(String label) {
- var mappedSubtype = type.mappedSubtype();
- if (mappedSubtype.rank() != 1)
- throw new IllegalArgumentException("Cannot add a label without explicit dimension to a tensor of type " +
- type + ": Must have exactly one sparse dimension");
- add(mappedSubtype.dimensions().get(0).name(), label);
+ if (type.rank() != 1)
+ throw new IllegalArgumentException("Cannot add a label without explicit dimension to a tensor of type " + type);
+ add(type.dimensions().get(0).name(), label);
return this;
}
@@ -222,39 +218,14 @@ public abstract class TensorAddress implements Comparable<TensorAddress> {
/** Returns the type of the tensor this address is being built for. */
public TensorType type() { return type; }
- void validate() {
+ public TensorAddress build() {
for (int i = 0; i < labels.length; i++)
if (labels[i] == null)
throw new IllegalArgumentException("Missing a label for dimension " +
type.dimensions().get(i).name() + " for " + type);
- }
-
- public TensorAddress build() {
- validate();
return TensorAddress.of(labels);
}
}
- /** Builder of an address to a subset of the dimensions of a tensor type */
- public static class PartialBuilder extends Builder {
-
- public PartialBuilder(TensorType type) {
- super(type);
- }
-
- private PartialBuilder(TensorType type, String[] labels) {
- super(type, labels);
- }
-
- /** Creates a copy of this which can be modified separately */
- public Builder copy() {
- return new PartialBuilder(type, Arrays.copyOf(labels, labels.length));
- }
-
- @Override
- void validate() { }
-
- }
-
}