Skip to content

GH-50654: [C++] Support simdjson without exceptions - #50672

Open
Reranko05 wants to merge 1 commit into
apache:mainfrom
Reranko05:gh-50654-excep-off
Open

GH-50654: [C++] Support simdjson without exceptions#50672
Reranko05 wants to merge 1 commit into
apache:mainfrom
Reranko05:gh-50654-excep-off

Conversation

@Reranko05

@Reranko05 Reranko05 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

This change enables building Arrow with SIMDJSON_EXCEPTIONS=0 by updating the JSON object parser to use simdjson's non-throwing API.

What changes are included?

  • Enable SIMDJSON_EXCEPTIONS=0 for the bundled simdjson dependency.
  • Replace uses of simdjson_result::value() in ObjectParser with the non-throwing get() API.
  • Preserve existing error handling by returning Arrow Status values on simdjson errors.

Are these changes tested?

Yes.

Fixes: #50654

@Reranko05
Reranko05 requested a review from pitrou as a code owner July 28, 2026 03:38
Copilot AI review requested due to automatic review settings July 28, 2026 03:38

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 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@kou @rok Could you review this when you have time? Thanks!

Comment thread cpp/src/arrow/json/object_parser.cc Outdated
@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Jul 28, 2026
Copilot AI review requested due to automatic review settings July 28, 2026 06:40
@Reranko05
Reranko05 force-pushed the gh-50654-excep-off branch from f94fe05 to fde573a Compare July 28, 2026 06: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.

@github-actions github-actions Bot added awaiting change review Awaiting change review awaiting changes Awaiting changes and removed awaiting changes Awaiting changes awaiting change review Awaiting change review labels Jul 28, 2026
@Reranko05
Reranko05 requested a review from kou July 28, 2026 07:15
Comment thread cpp/src/arrow/json/object_parser.cc Outdated

@kou kou left a comment

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.

+1

Copilot AI review requested due to automatic review settings July 28, 2026 08:41
@Reranko05
Reranko05 force-pushed the gh-50654-excep-off branch from fde573a to 92ae650 Compare July 28, 2026 08:41

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.

@github-actions github-actions Bot added awaiting change review Awaiting change review awaiting merge Awaiting merge and removed awaiting changes Awaiting changes awaiting change review Awaiting change review labels Jul 28, 2026
@Reranko05
Reranko05 requested a review from kou July 28, 2026 09:24
Comment on lines +74 to +79
std::string_view str;
if (auto error = std::move(str_result).get(str)) {
return Status::Invalid("Error getting string for key '", key,
"': ", simdjson::error_message(error));
}
return std::string(str);

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.

#50653 adds

template <typename SimdjsonValueType>
Result<SimdjsonValueType> GetJsonAs(sj::value& value) {

that already returns arrow::Results instead of error codes. This might simplify these type-casts

@Reranko05 Reranko05 Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions! I opened #50693 to track this cleanup after #50672 is merged.

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.

Well, #50653 is merged now :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted to write after this PR is merged. Referenced the wrong PR. Fixed it.

Comment on lines 90 to +115
@@ -102,7 +106,13 @@ class ObjectParser::Impl {
"': (code=", static_cast<int>(str_result.error()), ")");
}

map.emplace(std::string(key), std::string(str_result.value()));
std::string_view str;
if (auto error = std::move(str_result).get(str)) {
return Status::Invalid("Error getting value for key '", std::string(key),
"': ", simdjson::error_message(error));
}

map.emplace(std::string(key), std::string(str));

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.

auto field has type simdjson_result<sj::field>. If we first resolve this to a sj::field, we do not need duplicated value checks for the unescaped_key and value.

Also, first asserting the value (L110), then type-checking the value (L98), is cleaner IMO. (It also works the other way around because simdjson provides overloads for many methods on its result type)

Note that for asserting the value and type-checking the value #50653 adds helper methods we might want to reuse

Comment on lines +145 to +149
bool value;
if (auto error = std::move(bool_result).get(value)) {
return Status::Invalid("Error getting bool for key '", key,
"': ", simdjson::error_message(error));
}

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.

#50653 adds

template <typename SimdjsonValueType>
Result<SimdjsonValueType> GetJsonAs(sj::value& value) {

that already returns arrow::Results instead of error codes. This might simplify these type-casts

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.

[C++] Turn off exceptions in simdjson

6 participants