taepper commented on code in PR #50653:
URL: https://github.com/apache/arrow/pull/50653#discussion_r3663089653
##########
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:
Very good point, sorry for my oversight. I added two helper methods which
make the simdjson api fit a lot better into the code base on further
consideration. I left them inside the file for now, but we might want to move
them to a better location to include them in other simdjson users
--
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]