summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-16 12:01:24 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-16 12:01:24 +0100
commit53786a4c4bde1b53989916cf1eee6321d11d7e4d (patch)
tree53489e62e13c427ed40e943e1309b597aca90703 /document
parent3f07bf2d9e6eae85c50aa8734694273c983f959b (diff)
Test direct rendering
Diffstat (limited to 'document')
-rw-r--r--document/src/main/java/com/yahoo/document/json/readers/TensorReader.java3
-rw-r--r--document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java1
2 files changed, 3 insertions, 1 deletions
diff --git a/document/src/main/java/com/yahoo/document/json/readers/TensorReader.java b/document/src/main/java/com/yahoo/document/json/readers/TensorReader.java
index 9d66bbd25d9..f7b819e7eb8 100644
--- a/document/src/main/java/com/yahoo/document/json/readers/TensorReader.java
+++ b/document/src/main/java/com/yahoo/document/json/readers/TensorReader.java
@@ -125,6 +125,7 @@ public class TensorReader {
int index = 0;
int initNesting = buffer.nesting();
for (buffer.next(); buffer.nesting() >= initNesting; buffer.next()) {
+ if (buffer.current() == JsonToken.START_ARRAY || buffer.current() == JsonToken.END_ARRAY) continue; // nested arrays: Skip
indexedBuilder.cellByDirectIndex(index++, readDouble(buffer));
}
if (index == 0)
@@ -181,7 +182,7 @@ public class TensorReader {
/** Reads a tensor value directly at the root, where the format is decided by the tensor type. */
private static void readDirectTensorValue(TokenBuffer buffer, Tensor.Builder builder) {
- boolean hasIndexed = builder.type().dimensions().stream().anyMatch(TensorType.Dimension::isIndexed) && 1==2;
+ boolean hasIndexed = builder.type().dimensions().stream().anyMatch(TensorType.Dimension::isIndexed);
boolean hasMapped = builder.type().dimensions().stream().anyMatch(TensorType.Dimension::isMapped);
if (isArrayOfObjects(buffer, 0))
diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
index f48c2330f82..0c130ab9a42 100644
--- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
@@ -1512,6 +1512,7 @@ public class JsonReaderTestCase {
public void testDirectValue() {
assertTensorField("tensor(x{}):{a:2, b:3}", "sparse_single_dimension_tensor", "{'a':2.0, 'b':3.0}");
assertTensorField("tensor(x[2],y[3]):[2, 3, 4, 5, 6, 7]]", "dense_tensor", "[2, 3, 4, 5, 6, 7]");
+ assertTensorField("tensor(x[2],y[3]):[2, 3, 4, 5, 6, 7]]", "dense_tensor", "[[2, 3, 4], [5, 6, 7]]");
assertTensorField("tensor(x{},y[3]):{a:[2, 3, 4], b:[4, 5, 6]}", "mixed_tensor", "{'a':[2, 3, 4], 'b':[4, 5, 6]}");
assertTensorField("tensor(x{},y{}):{{x:a,y:0}:2, {x:b,y:1}:3}", "sparse_tensor",
"[{'address':{'x':'a','y':'0'},'value':2}, {'address':{'x':'b','y':'1'},'value':3}]");