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. |
75fc21a to
6c304b8
Compare
6c304b8 to
9519b33
Compare
9519b33 to
3673c4d
Compare
@kou @pitrou @taepper I am a bit confused about whether this failure is related to my PR, since another PR passes the same CI job even after I rebased mine. Could someone clarify? |
|
BTW, I have not yet updated the |
|
Hi, yes, I can take a look at this Can you quickly confirm my understanding re/ the commit history because I am a little bit confused (and the history has since been rebased & force-pushed) The initial commit
Yes, I would also think that your change to |
@taepper I initially used internal Arrow APIs to write the example code, then I got to know that I should write it in plain simdjson and then it was that my impl was row based but we needed column based iteration, so yeah they were considerable feedback changes 😅 |
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: