Skip to content

GH-51395: [C++][Docs] Replace RapidJSON with simdjson in row converter example - #51396

Open
Reranko05 wants to merge 7 commits into
apache:mainfrom
Reranko05:example-doc
Open

Reranko05 wants to merge 7 commits into
apache:mainfrom
Reranko05:example-doc

Conversation

@Reranko05

@Reranko05 Reranko05 commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Replace RapidJSON DOM parsing with simdjson's DOM API.
  • Replace RapidJSON JSON generation with Arrow's JsonWriter.
  • Preserve the existing row-to-Arrow and Arrow-to-row conversion flow.
  • Update the example to link against 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:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@Reranko05 Reranko05 added the CI: Extra: C++ Run extra C++ CI label Sep 19, 2026
@Reranko05 Reranko05 changed the title GH-51395: [C++] Replace RapidJSON with Simdjson in row converter example GH-51395: [C++] Replace RapidJSON with simdjson in row converter example Sep 19, 2026
@Reranko05 Reranko05 changed the title GH-51395: [C++] Replace RapidJSON with simdjson in row converter example GH-51395: [C++][Docs] Replace RapidJSON with simdjson in row converter example Sep 19, 2026
@Reranko05

Copy link
Copy Markdown
Collaborator Author

Will mark this PR Ready to Review after #51038 is merged.

@Reranko05
Reranko05 marked this pull request as ready for review October 8, 2026 09:37
@Reranko05
Reranko05 requested a review from pitrou as a code owner October 8, 2026 09:37
Copilot AI balanced review requested due to automatic review settings October 8, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05
Reranko05 requested a review from kou October 8, 2026 09:37
// * arrow::TableBatchReader and Arrow iterators for converting Arrow tables back
// into row-based JSON data

namespace arrow {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example code shouldn't be in the arrow namespace because it showcases how third-party code using Arrow C++ could look like.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay. I got it.

Comment on lines +41 to +42
// * arrow::internal::JsonWriter for writing JSON values
// * arrow::internal::ParseJsonObject and related helpers for parsing JSON

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examples should not use any internal Arrow APIs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, understood.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Oct 8, 2026
Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05

Copy link
Copy Markdown
Collaborator Author

I have not got the time to review this myself after changing it into plain simdjson. I will mark it as Ready for review after I review this.

@Reranko05
Reranko05 marked this pull request as draft October 11, 2026 09:52
@Reranko05
Reranko05 marked this pull request as ready for review October 16, 2026 11:19
Copilot AI balanced review requested due to automatic review settings October 16, 2026 11:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05

Copy link
Copy Markdown
Collaborator Author

@pitrou @kou Could you review this when you have time? (CI failures seem unrelated)

Comment on lines +189 to +208
// 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));
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said above.

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Oct 16, 2026
Copilot AI balanced review requested due to automatic review settings October 16, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05

Copy link
Copy Markdown
Collaborator Author

I have not updated the docs yet, once the impl is approved I will update the docs accordingly.

@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 16, 2026
Copilot AI balanced review requested due to automatic review settings October 17, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05
Reranko05 requested a review from kou October 17, 2026 13:51
@Reranko05

Copy link
Copy Markdown
Collaborator Author

@kou @pitrou Could you review this when you have time? Thanks :)

@Reranko05

Copy link
Copy Markdown
Collaborator Author
[1342/2536] Building CXX object _deps/grpc-build/CMakeFiles/grpc.dir/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc.o
FAILED: [code=1] _deps/grpc-build/CMakeFiles/grpc.dir/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc.o 
/opt/homebrew/bin/ccache /usr/bin/c++ -DARROW_HAVE_NEON -I/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src -I/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/third_party/address_sorting/include -I/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/src/core/ext/upb-gen -I/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/src/core/ext/upbdefs-gen -I/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/third_party/upb -I/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/third_party/utf8_range -I/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/third_party/xxhash -I/Users/runner/work/arrow/arrow/build/cpp/_deps/cares-build -I/Users/runner/work/arrow/arrow/build/cpp/_deps/cares-src -I/Users/runner/work/arrow/arrow/build/cpp/_deps/cares-src/include -isystem /Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/include -isystem /Users/runner/work/arrow/arrow/build/cpp/_deps/re2-src -isystem /Users/runner/work/arrow/arrow/build/cpp/zlib_ep/src/zlib_ep-install/include -isystem /Users/runner/work/arrow/arrow/build/cpp/_deps/absl-src -isystem /opt/homebrew/opt/openssl@4/include -fno-aligned-new  -I/opt/homebrew/Cellar/libiodbc/3.52.16/include -Qunused-arguments -fcolor-diagnostics  -Wall -Wno-unknown-warning-option -Wno-pass-failed -march=armv8-a  -Wno-attributes -Wno-format-security -Wno-unknown-warning-option  -g -O0 -ggdb -g1 -Wno-error -std=c++20 -arch arm64 -fPIC -Wno-error=deprecated-declarations -MD -MT _deps/grpc-build/CMakeFiles/grpc.dir/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc.o -MF _deps/grpc-build/CMakeFiles/grpc.dir/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc.o.d -o _deps/grpc-build/CMakeFiles/grpc.dir/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc.o -c /Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc
/Users/runner/work/arrow/arrow/build/cpp/_deps/grpc-src/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc:59:14: error: cannot initialize a variable of type 'X509_NAME *' (aka 'X509_name_st *') with an rvalue of type 'const X509_NAME *' (aka 'const X509_name_st *')
   59 |   X509_NAME* issuer = X509_CRL_get_issuer(crl);
      |              ^        ~~~~~~~~~~~~~~~~~~~~~~~~

@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?

@Reranko05

Copy link
Copy Markdown
Collaborator Author

BTW, I have not yet updated the .rst doc file, I will do that once the simdjson_row_converter.cc changes are approved.

@taepper

taepper commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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 Replace example was the first draft and the subsequent commits (which change the structure considerably), were the iterations based on review feedback?

@taepper I am a bit confused about whether this failure is related to my PR, since another #54839 passes the same CI job even after I rebased mine. Could someone clarify?

Yes, I would also think that your change to CMakeLists.txt is unrelated

@pitrou

pitrou commented Oct 22, 2026

Copy link
Copy Markdown
Member

@kou @pitrou @taepper I am a bit confused about whether this failure is related to my PR

It's not, we see it on other PRs as well.

@Reranko05

Copy link
Copy Markdown
Collaborator Author

Oh okay, thanks for confirming :)
This is ready for review.
cc @kou @pitrou @taepper

@Reranko05

Copy link
Copy Markdown
Collaborator Author

were the iterations based on review feedback?

@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 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants