pitrou commented on code in PR #50653:
URL: https://github.com/apache/arrow/pull/50653#discussion_r3657313412
##########
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:
Perhaps using some kind of helper that allows one to write e.g.:
```suggestion
ARROW_ASSIGN_OR_RAISE(
auto value,
GetJsonValue<sj::value>(element, "Could not iterate elements of JSON
array: "));
```
--
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]