mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
Fix JSON integration test example to make it further
Change-Id: Ifce9e8f23d98435b7ea841bdd5de4020d4bdeac3
This commit is contained in:
1 parent
d806aa679a
commit
c529d63e11
5 files changed
+53
-33
No files matched your search
@@ -398,7 +398,10 @@ Status RecordBatchReader::Open(io::ReadableFileInterface* file, int64_t offset,
|
||||
int32_t metadata_size = *reinterpret_cast<const int32_t*>(buffer->data());
|
||||
|
||||
if (metadata_size + static_cast<int>(sizeof(int32_t)) > offset) {
|
||||
return Status::Invalid("metadata size invalid");
|
||||
std::stringstream ss;
|
||||
ss << "metadata size " << metadata_size
|
||||
<< " invalid. File offset: " << offset;
|
||||
return Status::Invalid(ss.str());
|
||||
}
|
||||
|
||||
// Read the metadata
|
||||
|
||||
@@ -284,19 +284,23 @@ TEST(TestJsonFileReadWrite, MinimalFormatExample) {
|
||||
"name": "foo",
|
||||
"type": {"name": "int", "isSigned": true, "bitWidth": 32},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bar",
|
||||
"type": {"name": "floatingpoint", "precision": "DOUBLE"},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -255,19 +255,23 @@ static const char* JSON_EXAMPLE = R"example(
|
||||
"name": "foo",
|
||||
"type": {"name": "int", "isSigned": true, "bitWidth": 32},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bar",
|
||||
"type": {"name": "floatingpoint", "precision": "DOUBLE"},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -301,10 +305,12 @@ static const char* JSON_EXAMPLE2 = R"example(
|
||||
"name": "foo",
|
||||
"type": {"name": "int", "isSigned": true, "bitWidth": 32},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -261,6 +261,8 @@ class JsonSchemaWriter : public TypeVisitor {
|
||||
|
||||
void WriteBufferLayout(const std::vector<BufferLayout>& buffer_layout) {
|
||||
writer_->Key("typeLayout");
|
||||
writer_->StartObject();
|
||||
writer_->Key("vectors");
|
||||
writer_->StartArray();
|
||||
|
||||
for (const BufferLayout& buffer : buffer_layout) {
|
||||
@@ -274,6 +276,7 @@ class JsonSchemaWriter : public TypeVisitor {
|
||||
writer_->EndObject();
|
||||
}
|
||||
writer_->EndArray();
|
||||
writer_->EndObject();
|
||||
}
|
||||
|
||||
Status WriteChildren(const std::vector<std::shared_ptr<Field>>& children) {
|
||||
|
||||
@@ -5,19 +5,23 @@
|
||||
"name": "foo",
|
||||
"type": {"name": "int", "isSigned": true, "bitWidth": 32},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 32}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bar",
|
||||
"type": {"name": "floatingpoint", "precision": "DOUBLE"},
|
||||
"nullable": true, "children": [],
|
||||
"typeLayout": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
"typeLayout": {
|
||||
"vectors": [
|
||||
{"type": "VALIDITY", "typeBitWidth": 1},
|
||||
{"type": "DATA", "typeBitWidth": 64}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -28,14 +32,14 @@
|
||||
{
|
||||
"name": "foo",
|
||||
"count": 5,
|
||||
"DATA": [1, 2, 3, 4, 5],
|
||||
"VALIDITY": [1, 0, 1, 1, 1]
|
||||
"VALIDITY": [1, 0, 1, 1, 1],
|
||||
"DATA": [1, 2, 3, 4, 5]
|
||||
},
|
||||
{
|
||||
"name": "bar",
|
||||
"count": 5,
|
||||
"DATA": [1.0, 2.0, 3.0, 4.0, 5.0],
|
||||
"VALIDITY": [1, 0, 0, 1, 1]
|
||||
"VALIDITY": [1, 0, 0, 1, 1],
|
||||
"DATA": [1.0, 2.0, 3.0, 4.0, 5.0]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user