GH-51013: [C++] Replace RapidJSON in JSON test utilities - #51014
Open
Reranko05 wants to merge 5 commits into
Open
GH-51013: [C++] Replace RapidJSON in JSON test utilities#51014Reranko05 wants to merge 5 commits into
Reranko05 wants to merge 5 commits into
Conversation
Reranko05
force-pushed
the
gh-35460-tests
branch
from
August 26, 2026 23:04
932f311 to
8ed2513
Compare
pitrou
reviewed
Aug 27, 2026
| return Status::Invalid("Unreachable"); | ||
| } | ||
|
|
||
| inline Status PrettyPrintJsonValue(simdjson::ondemand::value value, std::string* out, |
Member
There was a problem hiding this comment.
Can we please move this to simdjson_internal.cc? There's no reason to inline the implement in the .h file.
Also, can this return Result<std::string>? It would be more idiomatic than an out-pointer parameter.
|
|
||
| #include <simdjson.h> | ||
|
|
||
| #include "arrow/json/json_writer_internal.h" |
Member
There was a problem hiding this comment.
We shouldn't be including arrow/json IMHO. Let's wait for #50990 to be merged perhaps?
| rj::PrettyWriter<rj::StringBuffer> writer(sb); | ||
| document.Accept(writer); | ||
| return sb.GetString(); | ||
| simdjson::padded_string json(one_line.data(), one_line.size()); |
Comment on lines
+557
to
+560
| auto json_result = writer.GetString(); | ||
| ABORT_NOT_OK(json_result.status()); | ||
| auto json_view = std::move(json_result).ValueOrDie(); | ||
| std::string json(json_view); |
Member
There was a problem hiding this comment.
I think you can write this more concisely as:
Suggested change
| auto json_result = writer.GetString(); | |
| ABORT_NOT_OK(json_result.status()); | |
| auto json_view = std::move(json_result).ValueOrDie(); | |
| std::string json(json_view); | |
| std::string json = writer.GetString().As<std::string>(); |
| R"([{"c":true, "d": "1991-02-03"}, {"c":false, "d":"2019-04-01"}])"}); | ||
| } | ||
|
|
||
| TEST(JsonTest, PrettyPrintEscapesObjectKeys) { |
Member
There was a problem hiding this comment.
This doesn't seem like a great place for this test but I can't think of anything better.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
This PR continues the simdjson migration by replacing RapidJSON usage in the C++ JSON test and testing utilities with simdjson and Arrow's existing
JsonWriter.Changes
rapidjson::WriterandStringBufferusage in JSON test utilities withJsonWriter.JsonWriterto correctly escape JSON object keys during pretty-printing.TensorFromJSON()with simdjson's DOM API.PrettyPrint().TensorFromJSON()with strides and dimension names.arrow::simdjson.