@@ -60,7 +60,7 @@ namespace json {
60
60
using ::arrow::internal::checked_cast;
61
61
using ::arrow::internal::checked_pointer_cast;
62
62
63
- namespace internal {
63
+ namespace {
64
64
65
65
constexpr auto kParseFlags = rj::kParseFullPrecisionFlag | rj::kParseNanAndInfFlag ;
66
66
@@ -90,9 +90,9 @@ Status JSONTypeError(const char* expected_type, rj::Type json_type) {
90
90
JsonTypeName (json_type));
91
91
}
92
92
93
- class Converter {
93
+ class JSONConverter {
94
94
public:
95
- virtual ~Converter () = default ;
95
+ virtual ~JSONConverter () = default ;
96
96
97
97
virtual Status Init () { return Status::OK (); }
98
98
@@ -117,11 +117,12 @@ class Converter {
117
117
std::shared_ptr<DataType> type_;
118
118
};
119
119
120
- Status GetConverter (const std::shared_ptr<DataType>&, std::shared_ptr<Converter>* out);
120
+ Status GetConverter (const std::shared_ptr<DataType>&,
121
+ std::shared_ptr<JSONConverter>* out);
121
122
122
123
// CRTP
123
124
template <class Derived >
124
- class ConcreteConverter : public Converter {
125
+ class ConcreteConverter : public JSONConverter {
125
126
public:
126
127
Result<int64_t > SizeOfJSONArray (const rj::Value& json_obj) {
127
128
if (!json_obj.IsArray ()) {
@@ -601,7 +602,7 @@ class VarLengthListLikeConverter final
601
602
602
603
private:
603
604
std::shared_ptr<BuilderType> builder_;
604
- std::shared_ptr<Converter > child_converter_;
605
+ std::shared_ptr<JSONConverter > child_converter_;
605
606
};
606
607
607
608
// ------------------------------------------------------------------------
@@ -653,7 +654,7 @@ class MapConverter final : public ConcreteConverter<MapConverter> {
653
654
654
655
private:
655
656
std::shared_ptr<MapBuilder> builder_;
656
- std::shared_ptr<Converter > key_converter_, item_converter_;
657
+ std::shared_ptr<JSONConverter > key_converter_, item_converter_;
657
658
};
658
659
659
660
// ------------------------------------------------------------------------
@@ -691,7 +692,7 @@ class FixedSizeListConverter final : public ConcreteConverter<FixedSizeListConve
691
692
private:
692
693
int32_t list_size_;
693
694
std::shared_ptr<FixedSizeListBuilder> builder_;
694
- std::shared_ptr<Converter > child_converter_;
695
+ std::shared_ptr<JSONConverter > child_converter_;
695
696
};
696
697
697
698
// ------------------------------------------------------------------------
@@ -704,7 +705,7 @@ class StructConverter final : public ConcreteConverter<StructConverter> {
704
705
Status Init () override {
705
706
std::vector<std::shared_ptr<ArrayBuilder>> child_builders;
706
707
for (const auto & field : type_->fields ()) {
707
- std::shared_ptr<Converter > child_converter;
708
+ std::shared_ptr<JSONConverter > child_converter;
708
709
RETURN_NOT_OK (GetConverter (field->type (), &child_converter));
709
710
child_converters_.push_back (child_converter);
710
711
child_builders.push_back (child_converter->builder ());
@@ -762,7 +763,7 @@ class StructConverter final : public ConcreteConverter<StructConverter> {
762
763
763
764
private:
764
765
std::shared_ptr<StructBuilder> builder_;
765
- std::vector<std::shared_ptr<Converter >> child_converters_;
766
+ std::vector<std::shared_ptr<JSONConverter >> child_converters_;
766
767
};
767
768
768
769
// ------------------------------------------------------------------------
@@ -783,7 +784,7 @@ class UnionConverter final : public ConcreteConverter<UnionConverter> {
783
784
}
784
785
std::vector<std::shared_ptr<ArrayBuilder>> child_builders;
785
786
for (const auto & field : type_->fields ()) {
786
- std::shared_ptr<Converter > child_converter;
787
+ std::shared_ptr<JSONConverter > child_converter;
787
788
RETURN_NOT_OK (GetConverter (field->type (), &child_converter));
788
789
child_converters_.push_back (child_converter);
789
790
child_builders.push_back (child_converter->builder ());
@@ -841,7 +842,7 @@ class UnionConverter final : public ConcreteConverter<UnionConverter> {
841
842
private:
842
843
UnionMode::type mode_;
843
844
std::shared_ptr<ArrayBuilder> builder_;
844
- std::vector<std::shared_ptr<Converter >> child_converters_;
845
+ std::vector<std::shared_ptr<JSONConverter >> child_converters_;
845
846
std::vector<int8_t > type_id_to_child_num_;
846
847
};
847
848
@@ -854,8 +855,8 @@ Status ConversionNotImplemented(const std::shared_ptr<DataType>& type) {
854
855
}
855
856
856
857
Status GetDictConverter (const std::shared_ptr<DataType>& type,
857
- std::shared_ptr<Converter >* out) {
858
- std::shared_ptr<Converter > res;
858
+ std::shared_ptr<JSONConverter >* out) {
859
+ std::shared_ptr<JSONConverter > res;
859
860
860
861
const auto value_type = checked_cast<const DictionaryType&>(*type).value_type ();
861
862
@@ -905,12 +906,12 @@ Status GetDictConverter(const std::shared_ptr<DataType>& type,
905
906
}
906
907
907
908
Status GetConverter (const std::shared_ptr<DataType>& type,
908
- std::shared_ptr<Converter >* out) {
909
+ std::shared_ptr<JSONConverter >* out) {
909
910
if (type->id () == Type::DICTIONARY) {
910
911
return GetDictConverter (type, out);
911
912
}
912
913
913
- std::shared_ptr<Converter > res;
914
+ std::shared_ptr<JSONConverter > res;
914
915
915
916
#define SIMPLE_CONVERTER_CASE (ID, CLASS ) \
916
917
case ID: \
@@ -972,15 +973,15 @@ Status GetConverter(const std::shared_ptr<DataType>& type,
972
973
return Status::OK ();
973
974
}
974
975
975
- } // namespace internal
976
+ } // namespace
976
977
977
978
Result<std::shared_ptr<Array>> ArrayFromJSONString (const std::shared_ptr<DataType>& type,
978
979
std::string_view json_string) {
979
- std::shared_ptr<internal::Converter > converter;
980
+ std::shared_ptr<JSONConverter > converter;
980
981
RETURN_NOT_OK (GetConverter (type, &converter));
981
982
982
983
rj::Document json_doc;
983
- json_doc.Parse <internal:: kParseFlags >(json_string.data (), json_string.length ());
984
+ json_doc.Parse <kParseFlags >(json_string.data (), json_string.length ());
984
985
if (json_doc.HasParseError ()) {
985
986
return Status::Invalid (" JSON parse error at offset " , json_doc.GetErrorOffset (), " : " ,
986
987
GetParseError_En (json_doc.GetParseError ()));
@@ -1037,11 +1038,11 @@ Status DictArrayFromJSONString(const std::shared_ptr<DataType>& type,
1037
1038
1038
1039
Status ScalarFromJSONString (const std::shared_ptr<DataType>& type,
1039
1040
std::string_view json_string, std::shared_ptr<Scalar>* out) {
1040
- std::shared_ptr<internal::Converter > converter;
1041
+ std::shared_ptr<JSONConverter > converter;
1041
1042
RETURN_NOT_OK (GetConverter (type, &converter));
1042
1043
1043
1044
rj::Document json_doc;
1044
- json_doc.Parse <internal:: kParseFlags >(json_string.data (), json_string.length ());
1045
+ json_doc.Parse <kParseFlags >(json_string.data (), json_string.length ());
1045
1046
if (json_doc.HasParseError ()) {
1046
1047
return Status::Invalid (" JSON parse error at offset " , json_doc.GetErrorOffset (), " : " ,
1047
1048
GetParseError_En (json_doc.GetParseError ()));
0 commit comments