pitrou commented on code in PR #50653:
URL: https://github.com/apache/arrow/pull/50653#discussion_r3657289173
##########
cpp/src/arrow/json/from_string.cc:
##########
@@ -124,20 +134,19 @@ Status GetConverter(const std::shared_ptr<DataType>&,
template <class Derived>
class ConcreteConverter : public JSONConverter {
public:
- Result<int64_t> SizeOfJSONArray(const rj::Value& json_obj) {
- if (!json_obj.IsArray()) {
- return JSONTypeError("array", json_obj.GetType());
- }
- return json_obj.Size();
- }
-
- Status AppendValues(const rj::Value& json_array) final {
+ Result<int32_t> AppendValues(sj::array& json_array) final {
auto self = static_cast<Derived*>(this);
- ARROW_ASSIGN_OR_RAISE(auto size, SizeOfJSONArray(json_array));
- for (uint32_t i = 0; i < size; ++i) {
- RETURN_NOT_OK(self->AppendValue(json_array[i]));
+ int32_t num_elements = 0;
+ for (auto element : json_array) {
+ sj::value value;
+ if (auto error_code = element.get(value); error_code !=
simdjson::SUCCESS) {
+ return Status::Invalid("Could not iterate elements of JSON array: ",
+ simdjson::error_message(error_code));
+ }
Review Comment:
Ok, but can we apply this pattern more thoroughly where simdjson gives us a
non-success?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]