summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-10-08 13:49:33 +0200
committerJon Bratseth <bratseth@verizonmedia.com>2019-10-08 13:49:33 +0200
commitee1bf523a2cfb5e8d86a602323c337f6e55c202b (patch)
treeb53f3ea4f58008f1e01f7314d826cc2291d3d995 /vespajlib
parent979693367c5d6bf0fc581d9d960cf86705c17264 (diff)
Simplify
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/serialization/JsonFormat.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/serialization/JsonFormat.java b/vespajlib/src/main/java/com/yahoo/tensor/serialization/JsonFormat.java
index 664f1ec23a4..75690e45e15 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/serialization/JsonFormat.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/serialization/JsonFormat.java
@@ -78,19 +78,17 @@ public class JsonFormat {
private static void decodeCells(Inspector cells, Tensor.Builder builder) {
if ( cells.type() != Type.ARRAY)
throw new IllegalArgumentException("Excepted 'cells' to contain an array, not " + cells.type());
- cells.traverse((ArrayTraverser) (__, cell) -> decodeCell(cell, builder.cell()));
+ cells.traverse((ArrayTraverser) (__, cell) -> decodeCell(cell, builder));
}
- private static void decodeCell(Inspector cell, Tensor.Builder.CellBuilder cellBuilder) {
- Inspector address = cell.field("address");
- if ( address.type() != Type.OBJECT)
- throw new IllegalArgumentException("Excepted a cell to contain an object called 'address'");
- address.traverse((ObjectTraverser) (dimension, label) -> cellBuilder.label(dimension, label.asString()));
+ private static void decodeCell(Inspector cell, Tensor.Builder builder) {
+ TensorAddress address = decodeAddress(cell.field("address"), builder.type());
Inspector value = cell.field("value");
if (value.type() != Type.LONG && value.type() != Type.DOUBLE)
throw new IllegalArgumentException("Excepted a cell to contain a numeric value called 'value'");
- cellBuilder.value(value.asDouble());
+
+ builder.cell(address, value.asDouble());
}
private static void decodeValues(Inspector values, Tensor.Builder builder) {