Copilot commented on code in PR #50725:
URL: https://github.com/apache/arrow/pull/50725#discussion_r3694602060


##########
cpp/src/arrow/util/simdjson_internal.h:
##########
@@ -0,0 +1,231 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string_view>
+
+#include <simdjson.h>

Review Comment:
   This header uses `int64_t`/`uint64_t`, `std::is_same_v`, and `std::move` but 
doesn't include `<cstdint>`, `<type_traits>`, or `<utility>`. Relying on 
transitive includes in a widely included header can break builds depending on 
include order.



##########
cpp/src/arrow/json/json_writer_internal.cc:
##########
@@ -96,6 +99,101 @@ void JsonWriter::Double(double value) {
   needs_comma_ = true;
 }
 
+Status JsonWriter::WriteValue(sj::value value) {
+  return internal::VisitJsonValue(
+      value,
+

Review Comment:
   `VisitJsonValue` expects 9 handlers 
(object/array/string/bool/null/int64/uint64/double/big_integer), but 
`WriteValue` passes only 6 and the last lambda takes `sj::value` (it will be 
invoked with `int64_t`/`uint64_t`/`double`). This will not compile and also 
duplicates number-type dispatch that `VisitJsonValue` already performs.



##########
cpp/src/arrow/json/json_writer_internal_test.cc:
##########
@@ -170,4 +172,116 @@ TEST(JsonWriter, StringWithExplicitLength) {
   EXPECT_EQ(json, R"({"value":"abc"})");
 }
 
+TEST(JsonWriter, WriteValueSimpleObject) {
+  sj::parser parser;
+  std::string json_str = R"({"a":42,"b":"hello"})";
+  simdjson::padded_string json(json_str);
+
+  sj::document doc;
+  ASSERT_EQ(parser.iterate(json).get(doc), simdjson::SUCCESS);
+
+  sj::value value;
+  ASSERT_EQ(doc.get_value().get(value), simdjson::SUCCESS);
+
+  JsonWriter writer;
+  ASSERT_OK(writer.WriteValue(value));
+
+  EXPECT_EQ(writer.GetString(), R"({"a":42,"b":"hello"})");

Review Comment:
   `JsonWriter::GetString()` returns `Result<std::string_view>`, but these new 
tests compare it directly in `EXPECT_EQ`, which won't compile. Use 
`ASSERT_OK_AND_ASSIGN` (as earlier tests in this file do) and compare the 
extracted `std::string_view`. Apply the same fix to the other `WriteValue*` 
tests below.



-- 
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]

Reply via email to