Repository navigation
Conversation
3842058 to
9813fc2
Compare
|
Will mark this PR |
| // * arrow::TableBatchReader and Arrow iterators for converting Arrow tables back | ||
| // into row-based JSON data | ||
|
|
||
| namespace arrow { |
There was a problem hiding this comment.
Example code shouldn't be in the arrow namespace because it showcases how third-party code using Arrow C++ could look like.
There was a problem hiding this comment.
Ah, okay. I got it.
| // * arrow::internal::JsonWriter for writing JSON values | ||
| // * arrow::internal::ParseJsonObject and related helpers for parsing JSON |
There was a problem hiding this comment.
Examples should not use any internal Arrow APIs.
There was a problem hiding this comment.
Okay, understood.
|
I have not got the time to review this myself after changing it into plain simdjson. I will mark it as |
| // Parse each row and append its values to the corresponding Arrow builders. | ||
| for (const auto& json : rows) { | ||
| ARROW_ASSIGN_OR_RAISE(auto element, | ||
| Unwrap(parser.parse(json), "Failed to parse JSON row")); | ||
| ARROW_ASSIGN_OR_RAISE(auto object, | ||
| Unwrap(element.get_object(), "Expected a JSON object")); | ||
|
|
||
| for (int i = 0; i < schema->num_fields(); ++i) { | ||
| const auto& field = schema->field(i); | ||
| arrow::ArrayBuilder* builder = batch_builder->GetField(i); | ||
|
|
||
| ARROW_ASSIGN_OR_RAISE(auto value, GetField(object, field->name())); | ||
|
|
||
| if (!value.has_value()) { | ||
| ARROW_RETURN_NOT_OK(builder->AppendNull()); | ||
| } else { | ||
| ARROW_RETURN_NOT_OK(AppendJsonValue(*value, field->type(), builder)); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Can we keep column based iteration (not row based iteration) like the RapidJSON version so that we demonstrate how to use a visitor to convert row based data to Arrow data?
There was a problem hiding this comment.
I changed the impl to do column based iteration.
| for (int64_t i = 0; i < batch->num_rows(); ++i) { | ||
| ARROW_ASSIGN_OR_RAISE(auto row, ConvertRowToJson(*batch, i)); | ||
| rows.push_back(std::make_shared<std::string>(std::move(row))); | ||
| } |
There was a problem hiding this comment.
Can we keep column based iteration (not row based iteration) like the RapidJSON version so that we demonstrate how to use a visitor to convert Arrow data to row based data?
|
I have not updated the docs yet, once the impl is approved I will update the docs accordingly. |
Rationale for this change
This PR continues the simdjson migration by replacing RapidJSON usage in the C++ row converter example with simdjson and Arrow's existing
JsonWriter.Changes
JsonWriter.arrow::simdjson.Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by: