From 93f77bbf3a18c9b25fab34e5f737b66af751a4e3 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 3 Jun 2025 11:24:43 -0700 Subject: [PATCH] Rename instead of add internal ns --- cpp/src/arrow/json/from_string.cc | 43 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/cpp/src/arrow/json/from_string.cc b/cpp/src/arrow/json/from_string.cc index 006a7299feb7..b2972f7150e8 100644 --- a/cpp/src/arrow/json/from_string.cc +++ b/cpp/src/arrow/json/from_string.cc @@ -60,7 +60,7 @@ namespace json { using ::arrow::internal::checked_cast; using ::arrow::internal::checked_pointer_cast; -namespace internal { +namespace { constexpr auto kParseFlags = rj::kParseFullPrecisionFlag | rj::kParseNanAndInfFlag; @@ -90,9 +90,9 @@ Status JSONTypeError(const char* expected_type, rj::Type json_type) { JsonTypeName(json_type)); } -class Converter { +class JSONConverter { public: - virtual ~Converter() = default; + virtual ~JSONConverter() = default; virtual Status Init() { return Status::OK(); } @@ -117,11 +117,12 @@ class Converter { std::shared_ptr type_; }; -Status GetConverter(const std::shared_ptr&, std::shared_ptr* out); +Status GetConverter(const std::shared_ptr&, + std::shared_ptr* out); // CRTP template -class ConcreteConverter : public Converter { +class ConcreteConverter : public JSONConverter { public: Result SizeOfJSONArray(const rj::Value& json_obj) { if (!json_obj.IsArray()) { @@ -601,7 +602,7 @@ class VarLengthListLikeConverter final private: std::shared_ptr builder_; - std::shared_ptr child_converter_; + std::shared_ptr child_converter_; }; // ------------------------------------------------------------------------ @@ -653,7 +654,7 @@ class MapConverter final : public ConcreteConverter { private: std::shared_ptr builder_; - std::shared_ptr key_converter_, item_converter_; + std::shared_ptr key_converter_, item_converter_; }; // ------------------------------------------------------------------------ @@ -691,7 +692,7 @@ class FixedSizeListConverter final : public ConcreteConverter builder_; - std::shared_ptr child_converter_; + std::shared_ptr child_converter_; }; // ------------------------------------------------------------------------ @@ -704,7 +705,7 @@ class StructConverter final : public ConcreteConverter { Status Init() override { std::vector> child_builders; for (const auto& field : type_->fields()) { - std::shared_ptr child_converter; + std::shared_ptr child_converter; RETURN_NOT_OK(GetConverter(field->type(), &child_converter)); child_converters_.push_back(child_converter); child_builders.push_back(child_converter->builder()); @@ -762,7 +763,7 @@ class StructConverter final : public ConcreteConverter { private: std::shared_ptr builder_; - std::vector> child_converters_; + std::vector> child_converters_; }; // ------------------------------------------------------------------------ @@ -783,7 +784,7 @@ class UnionConverter final : public ConcreteConverter { } std::vector> child_builders; for (const auto& field : type_->fields()) { - std::shared_ptr child_converter; + std::shared_ptr child_converter; RETURN_NOT_OK(GetConverter(field->type(), &child_converter)); child_converters_.push_back(child_converter); child_builders.push_back(child_converter->builder()); @@ -841,7 +842,7 @@ class UnionConverter final : public ConcreteConverter { private: UnionMode::type mode_; std::shared_ptr builder_; - std::vector> child_converters_; + std::vector> child_converters_; std::vector type_id_to_child_num_; }; @@ -854,8 +855,8 @@ Status ConversionNotImplemented(const std::shared_ptr& type) { } Status GetDictConverter(const std::shared_ptr& type, - std::shared_ptr* out) { - std::shared_ptr res; + std::shared_ptr* out) { + std::shared_ptr res; const auto value_type = checked_cast(*type).value_type(); @@ -905,12 +906,12 @@ Status GetDictConverter(const std::shared_ptr& type, } Status GetConverter(const std::shared_ptr& type, - std::shared_ptr* out) { + std::shared_ptr* out) { if (type->id() == Type::DICTIONARY) { return GetDictConverter(type, out); } - std::shared_ptr res; + std::shared_ptr res; #define SIMPLE_CONVERTER_CASE(ID, CLASS) \ case ID: \ @@ -972,15 +973,15 @@ Status GetConverter(const std::shared_ptr& type, return Status::OK(); } -} // namespace internal +} // namespace Result> ArrayFromJSONString(const std::shared_ptr& type, std::string_view json_string) { - std::shared_ptr converter; + std::shared_ptr converter; RETURN_NOT_OK(GetConverter(type, &converter)); rj::Document json_doc; - json_doc.Parse(json_string.data(), json_string.length()); + json_doc.Parse(json_string.data(), json_string.length()); if (json_doc.HasParseError()) { return Status::Invalid("JSON parse error at offset ", json_doc.GetErrorOffset(), ": ", GetParseError_En(json_doc.GetParseError())); @@ -1037,11 +1038,11 @@ Status DictArrayFromJSONString(const std::shared_ptr& type, Status ScalarFromJSONString(const std::shared_ptr& type, std::string_view json_string, std::shared_ptr* out) { - std::shared_ptr converter; + std::shared_ptr converter; RETURN_NOT_OK(GetConverter(type, &converter)); rj::Document json_doc; - json_doc.Parse(json_string.data(), json_string.length()); + json_doc.Parse(json_string.data(), json_string.length()); if (json_doc.HasParseError()) { return Status::Invalid("JSON parse error at offset ", json_doc.GetErrorOffset(), ": ", GetParseError_En(json_doc.GetParseError()));