mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
Fix logical error with offsets array in JsonFileWriter. Add broken string test case to simple.json
Change-Id: If62adb8cc209868e105f07f276c54140fe366df5
This commit is contained in:
1 parent
36ab5d6827
commit
4d46c8bd2b
3 files changed
+27
-3
No files matched your search
@@ -22,6 +22,18 @@
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "baz",
|
||||
"type": {"name": "utf8"},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "OFFSET", "typeBitWidth": 32},
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -40,6 +52,13 @@
|
||||
"count": 5,
|
||||
"VALIDITY": [1, 0, 0, 1, 1],
|
||||
"DATA": [1.0, 2.0, 3.0, 4.0, 5.0]
|
||||
},
|
||||
{
|
||||
"name": "baz",
|
||||
"count": 5,
|
||||
"VALIDITY": [1, 0, 0, 1, 1],
|
||||
"OFFSET": [0, 2, 2, 2, 5, 9],
|
||||
"DATA": ["aa", "", "", "bbb", "cccc"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -127,8 +127,13 @@ public class JsonFileReader implements AutoCloseable {
|
||||
ValueVector valueVector = (ValueVector)innerVector;
|
||||
valueVector.allocateNew();
|
||||
Mutator mutator = valueVector.getMutator();
|
||||
mutator.setValueCount(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
int innerVectorCount = count;
|
||||
if (vectorType.getName() == "OFFSET") {
|
||||
innerVectorCount++;
|
||||
}
|
||||
mutator.setValueCount(innerVectorCount);
|
||||
for (int i = 0; i < innerVectorCount; i++) {
|
||||
parser.nextToken();
|
||||
setValueFromParser(valueVector, i);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class JsonFileWriter implements AutoCloseable {
|
||||
BufferBacked innerVector = fieldInnerVectors.get(v);
|
||||
generator.writeArrayFieldStart(vectorType.getName());
|
||||
ValueVector valueVector = (ValueVector)innerVector;
|
||||
for (int i = 0; i < valueCount; i++) {
|
||||
for (int i = 0; i < valueVector.getAccessor().getValueCount(); i++) {
|
||||
writeValueToGenerator(valueVector, i);
|
||||
}
|
||||
generator.writeEndArray();
|
||||
|
||||
Reference in new issue
Block a user