aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/tensor/serialization
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-01-10 18:05:05 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2017-01-10 18:05:05 +0100
commitce1e83dfa0446711f9945c9dbf8f185df9e523e4 (patch)
tree83b60e50f730ca6a598179a62d73b89f0c530e25 /vespajlib/src/main/java/com/yahoo/tensor/serialization
parent662269815664134d83d86bd5143af251bc653d3e (diff)
Propagate type
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/tensor/serialization')
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/serialization/SparseBinaryFormat.java14
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java2
2 files changed, 2 insertions, 14 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/serialization/SparseBinaryFormat.java b/vespajlib/src/main/java/com/yahoo/tensor/serialization/SparseBinaryFormat.java
index 30b36e83457..8ab23c8d77c 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/serialization/SparseBinaryFormat.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/serialization/SparseBinaryFormat.java
@@ -54,24 +54,12 @@ class SparseBinaryFormat implements BinaryFormat {
@Override
public Tensor decode(TensorType type, GrowableByteBuffer buffer) {
- if (type == null) // TODO (January 2017): Remove this when types are available
- type = decodeDimensionsToType(buffer);
- else
- consumeAndValidateDimensions(type, buffer);
+ consumeAndValidateDimensions(type, buffer);
Tensor.Builder builder = Tensor.Builder.of(type);
decodeCells(buffer, builder, type);
return builder.build();
}
- private TensorType decodeDimensionsToType(GrowableByteBuffer buffer) {
- TensorType.Builder builder = new TensorType.Builder();
- int numDimensions = buffer.getInt1_4Bytes();
- for (int i = 0; i < numDimensions; ++i) {
- builder.mapped(buffer.getUtf8String());
- }
- return builder.build();
- }
-
private void consumeAndValidateDimensions(TensorType type, GrowableByteBuffer buffer) {
int dimensionCount = buffer.getInt1_4Bytes();
if (type.dimensions().size() != dimensionCount)
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java b/vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java
index 65216aa2fcd..19c1810d928 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java
@@ -24,7 +24,7 @@ public class TypedBinaryFormat {
public static byte[] encode(Tensor tensor) {
GrowableByteBuffer buffer = new GrowableByteBuffer();
- if (tensor instanceof IndexedTensor && 1==2) { // TODO: Activate when we have type information everywhere
+ if (tensor instanceof IndexedTensor) {
buffer.putInt1_4Bytes(DENSE_BINARY_FORMAT_TYPE);
new DenseBinaryFormat().encode(buffer, tensor);
}