summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-12-19 23:02:04 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2017-12-19 23:02:04 +0100
commit35d59981840614bf4b877714ee88e273816c46d2 (patch)
treefba37b2e8bc9fcee46821821ab2886d371fcd696 /vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
parent067eb48b7d2fc062a74392b1c16f5538b5031d5b (diff)
Use longs for dimensions lengths in all API's
This is to be able to support tensor dimensions with more than 2B elements in the future without API change.
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/tensor/TensorType.java')
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorType.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
index 914d853aeca..b396f831de0 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
@@ -139,7 +139,7 @@ public class TensorType {
public final String name() { return name; }
/** Returns the size of this dimension if it is bound, empty otherwise */
- public abstract Optional<Integer> size();
+ public abstract Optional<Long> size();
public abstract Type type();
@@ -189,7 +189,7 @@ public class TensorType {
return this.name.compareTo(other.name);
}
- public static Dimension indexed(String name, int size) {
+ public static Dimension indexed(String name, long size) {
return new IndexedBoundDimension(name, size);
}
@@ -197,17 +197,19 @@ public class TensorType {
public static class IndexedBoundDimension extends TensorType.Dimension {
- private final Integer size;
+ private final Long size;
- private IndexedBoundDimension(String name, int size) {
+ private IndexedBoundDimension(String name, long size) {
super(name);
if (size < 1)
throw new IllegalArgumentException("Size of bound dimension '" + name + "' must be at least 1");
+ if (size > Integer.MAX_VALUE)
+ throw new IllegalArgumentException("Size of bound dimension '" + name + "' cannot be larger than " + Integer.MAX_VALUE);
this.size = size;
}
@Override
- public Optional<Integer> size() { return Optional.of(size); }
+ public Optional<Long> size() { return Optional.of(size); }
@Override
public Type type() { return Type.indexedBound; }
@@ -248,7 +250,7 @@ public class TensorType {
}
@Override
- public Optional<Integer> size() { return Optional.empty(); }
+ public Optional<Long> size() { return Optional.empty(); }
@Override
public Type type() { return Type.indexedUnbound; }
@@ -269,7 +271,7 @@ public class TensorType {
}
@Override
- public Optional<Integer> size() { return Optional.empty(); }
+ public Optional<Long> size() { return Optional.empty(); }
@Override
public Type type() { return Type.mapped; }
@@ -357,7 +359,7 @@ public class TensorType {
*
* @throws IllegalArgumentException if the dimension is already present
*/
- public Builder indexed(String name, int size) { return add(new IndexedBoundDimension(name, size)); }
+ public Builder indexed(String name, long size) { return add(new IndexedBoundDimension(name, size)); }
/**
* Adds an unbound indexed dimension to this