diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-01-10 18:05:05 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-01-10 18:05:05 +0100 |
commit | ce1e83dfa0446711f9945c9dbf8f185df9e523e4 (patch) | |
tree | 83b60e50f730ca6a598179a62d73b89f0c530e25 /vespajlib | |
parent | 662269815664134d83d86bd5143af251bc653d3e (diff) |
Propagate type
Diffstat (limited to 'vespajlib')
4 files changed, 3 insertions, 16 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java index 2fc65065caf..b0132693fa3 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java @@ -83,7 +83,7 @@ public class TensorType { for (int i = 0; i < other.dimensions().size(); i++) { Dimension thisDimension = this.dimensions().get(i); Dimension otherDimension = other.dimensions().get(i); - if (thisDimension.isIndexed() != other.isIndexed()) return false; + if (thisDimension.isIndexed() != otherDimension.isIndexed()) return false; if ( ! thisDimension.name().equals(otherDimension.name())) return false; if (thisDimension.size().isPresent()) { if ( ! otherDimension.size().isPresent()) return false; 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); } diff --git a/vespajlib/src/test/java/com/yahoo/tensor/serialization/DenseBinaryFormatTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/serialization/DenseBinaryFormatTestCase.java index d2b2044f3ed..15e82e6b15c 100644 --- a/vespajlib/src/test/java/com/yahoo/tensor/serialization/DenseBinaryFormatTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/tensor/serialization/DenseBinaryFormatTestCase.java @@ -28,7 +28,6 @@ public class DenseBinaryFormatTestCase { } @Test - @Ignore // TODO: Activate when encoding in this format is activated public void requireThatSerializationFormatDoNotChange() { byte[] encodedTensor = new byte[]{2, // binary format type 2, // dimension count |