MCPcopy Create free account
hub / github.com/apache/arrow / Convert

Method Convert

cpp/src/arrow/json/converter.cc:119–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117 : PrimitiveConverter(pool, type), numeric_type_(checked_cast<const T&>(*type)) {}
118
119 Status Convert(const std::shared_ptr<Array>& in, std::shared_ptr<Array>* out) override {
120 if (in->type_id() == Type::NA) {
121 return MakeArrayOfNull(out_type_, in->length(), pool_).Value(out);
122 }
123 const auto& dict_array = GetDictionaryArray(in);
124
125 using Builder = typename TypeTraits<T>::BuilderType;
126 Builder builder(out_type_, pool_);
127 RETURN_NOT_OK(builder.Resize(dict_array.indices()->length()));
128
129 auto visit_valid = [&](string_view repr) {
130 value_type value;
131 if (!arrow::internal::ParseValue(numeric_type_, repr.data(), repr.size(), &value)) {
132 return GenericConversionError(*out_type_, ", couldn't parse:", repr);
133 }
134
135 builder.UnsafeAppend(value);
136 return Status::OK();
137 };
138
139 auto visit_null = [&]() {
140 builder.UnsafeAppendNull();
141 return Status::OK();
142 };
143
144 RETURN_NOT_OK(VisitDictionaryEntries(dict_array, visit_valid, visit_null));
145 return builder.Finish(out);
146 }
147
148 const T& numeric_type_;
149};

Callers

nothing calls this directly

Calls 15

MakeArrayOfNullFunction · 0.85
ParseValueFunction · 0.85
VisitDictionaryEntriesFunction · 0.85
indicesMethod · 0.80
GenericConversionErrorFunction · 0.70
OKFunction · 0.70
type_idMethod · 0.45
ValueMethod · 0.45
lengthMethod · 0.45
ResizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected